Mosquito::Queue
A named Queue.
Named Queues exist and have 4 ordered lists: waiting, pending, scheduled, and dead.
- The Waiting list is for jobs which need to be executed as soon as possible.
- The Pending list is for jobs which are currently being executed.
- The Scheduled list is indexed by execution time and holds jobs which need to be executed at a later time.
- The Dead list is for jobs which have been retried too many times and are no longer viable.
A job_run is represented in a queue by its id.
A job_run flows through the queues in this manner:
Time=0: JobRun does not exist yet, lists are empty
Waiting Pending Scheduled Dead
---------------------------------
Time=1: JobRun is enqueued
Waiting Pending Scheduled Dead
JobRun#1
---------------------------------
Time=2: JobRun begins. JobRun is moved to pending and executed
Waiting Pending Scheduled Dead
JobRun#1
---------------------------------
Time=3: JobRuns are Enqueued.
Waiting Pending Scheduled Dead
JobRun#2 JobRun#1
JobRun#3
---------------------------------
Time=4: JobRun succeeds, next job_run begins.
Waiting Pending Scheduled Dead
JobRun#3 JobRun#2
---------------------------------
Time=5: JobRun fails and is scheduled for later, next job_run begins.
Waiting Pending Scheduled Dead
JobRun#3 t=7:JobRun#2
---------------------------------
Time=6: JobRun succeeds. Nothing is executing.
Waiting Pending Scheduled Dead
t=7:JobRun#2
---------------------------------
Time=7: Scheduled job_run is due and is moved to waiting. Nothing is executing.
Waiting Pending Scheduled Dead
JobRun#2
---------------------------------
Time=8: JobRun begins executing (for the second time).
Waiting Pending Scheduled Dead
JobRun#2
---------------------------------
Time=9: JobRun finished successfully. No more job_runs present.
Waiting Pending Scheduled Dead
Constants
Log = ::Log.for(self)
Constructors
Instance methods
backend
Sourcebackend=(backend : Mosquito::Backend)
Sourcebanish(job_run : JobRun)
Sourceconfig_key
Sourcedequeue
Sourcedequeue_scheduled
Sourceempty?
Sourceenqueue(job_run : JobRun) : JobRun
Sourceflush
Sourceforget(job_run : JobRun)
Sourcename
Sourcereschedule(job_run : JobRun, execution_time)
Sourcesize
Source