Skip to content

wassimbj/simpleq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I just built this project for learning, but if you like the simplicity why not give a hand.

Install

go get https://github.com/wassimbj/simpleq

how it works

/*

* The big picture of how the task queue works
                           ← ← ← ← ← ← ← ← ← ← ←
                          ↓                    ↑
                          ↓            --> failed => re-queue the job to the active queue
                  -- > active       /
                /                  /
job -> queue ->               ---> 
                \                  \
                 -- > delayed       \  --> completed => remove the job

*/

Example

a better one

emailsQueue := NewQueue("queueName", QueueOpts{
   client: redis.NewClient(&redis.Options{
      Addr:     "localhost:3434",
      Password: "",
   }),
})

emailsQueue.Process(func(job interface{}) error {
   fmt.Println("Job to process: ", job)
   return nil
})

emailsQueue.Add("welcome email")
emailsQueue.Add("delayed job, will exec after 7 sec", JobOpts{
   delay: int64((time.Second * 7) / time.Millisecond),
})


emailsQueue.Wait()

TODO

  • Add Cron Jobs
  • Add Priorities
  • Rate limiter for jobs

About

simple redis-based task queue for background processing, written in Go

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages