GithubHelp home page GithubHelp logo

wang502 / gores Goto Github PK

View Code? Open in Web Editor NEW
138.0 14.0 14.0 87 KB

:construction_worker: Redis-backed library for creating background jobs in Go. Placing jobs in multiple queues, and process them later asynchronously.

License: MIT License

Go 100.00%
redis message-queue go microservice workers asynchronously enqueue dispatch

gores's People

Contributors

wang502 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gores's Issues

Dispatcher stops fetching jobs from Redis queue when it shouldn't

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.

Buffered job channel in Dispatcher brings unfairness among workers

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

Cleanup non issue

When my account was compromised a spam issue was created in this repo. I sincerely apologize. Cleaning up such issues via script.

Job interface

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.