Queue == Que == Q
A basic job queue implemented in Go.
Taskis the basic unit of work that we want to run.Jobcontains >= 1 relatedTask(s).Queuecontains jobs and determines how/when to execute certainJobs.JobQis just a runner that runs readyJobs.
- Both
QueueandTaskare interfaces that you can easily implement and provide additional fields to. PriorityQueueis provided as a default to use withJobQ.- It is heap-based, so it implements the methods necessary for container/heap.
Job.Prioritycan be anything as long as they can be converted/encoded toint(string, date, numbers, etc.).- Jobs must run sequentially (due to priority), but tasks in a job can run either sequentially or concurrently.
Do take a look at jobq_test.go to see how JobQ is used.