wang502 / gores Goto Github PK
View Code? Open in Web Editor NEW:construction_worker: Redis-backed library for creating background jobs in Go. Placing jobs in multiple queues, and process them later asynchronously.
License: MIT License
:construction_worker: Redis-backed library for creating background jobs in Go. Placing jobs in multiple queues, and process them later asynchronously.
License: MIT License
Right now, Dispatcher struct has a jobChan
with length equals to the number of workers, workers keeps trying to fetch job from jobChan
. The execution time of each worker is different, so it may occur that some workers execute a lot more jobs than other workers.
Solved in commit 57
The Job interface is not very necessary. Since the job
struct is more about the field inside of it, rather than about the behavior or methods. Just create mock job structs in the job_test.go
Inside dispacher.go
func (disp *Dispatcher) Dispatch(wg *sync.WaitGroup){
for {
select {
case workerID := <-workerIDChan:
go func(workerID string){ // goroutine g1
for {
job := ReserveJob(disp.resq, disp.queues, workerID)
if job != nil {
disp.jobChannel<-job
}
}
}(workerID)
case <-time.After(time.Second * time.Duration(disp.timeout)):
log.Println("Timeout: Dispatch")
break
}
break
}
wg.Done()
}
Goroutine g1 will stop after the Dispatch() function returns. When there is no more workerID fetched from worker channel and time is out waiting for worker channel, the outer for loop breaks and Dispatch() returns, so then g1 will stop.
Since gouroutine g1 is used to fetch jobs from Redis, after it stops, there might be unfinished jobs waiting in Redis queue.
When my account was compromised a spam issue was created in this repo. I sincerely apologize. Cleaning up such issues via script.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.