class

Mosquito::Queue

Inherits Reference < Object

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

new(name : String)
Source

Instance methods

==(other : self) : Bool

Returns true if this reference is the same as other. Invokes same?.

Source
backend
Source
backend=(backend : Mosquito::Backend)
Source
banish(job_run : JobRun)
Source
config_key
Source
dequeue
Source
dequeue_scheduled
Source
empty?
Source
enqueue(job_run : JobRun, in interval : Time::Span) : JobRun
Source
enqueue(job_run : JobRun, at execute_time : Time) : JobRun
Source
enqueue(job_run : JobRun) : JobRun
Source
flush
Source
forget(job_run : JobRun)
Source
length

DEPRECATED see #size

Source
name
Source
reschedule(job_run : JobRun, execution_time)
Source
size
Source