class Mosquito::Queue
- Mosquito::Queue
- Reference
- Object
Overview
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
Defined in:
mosquito/queue.crConstant Summary
-
Log =
::Log.for(self)
Constructors
Instance Method Summary
-
#==(other : self) : Bool
Returns
true
if this reference is the same as other. - #backend : Mosquito::Backend
- #backend=(backend : Mosquito::Backend)
- #banish(job_run : JobRun)
- #config_key : String
- #dequeue : JobRun | Nil
- #dequeue_scheduled : Array(JobRun)
- #empty? : Bool
- #enqueue(job_run : JobRun, in interval : Time::Span) : JobRun
- #enqueue(job_run : JobRun, at execute_time : Time) : JobRun
- #enqueue(job_run : JobRun) : JobRun
- #flush
- #forget(job_run : JobRun)
- #name : String
- #reschedule(job_run : JobRun, execution_time)
- #size(*, include_dead : Bool = true) : Int64
Constructor Detail
Instance Method Detail
def ==(other : self) : Bool
#
Description copied from class Reference
Returns true
if this reference is the same as other. Invokes same?
.