class Mosquito::Queue

Overview

A named Queue.

Named Queues exist and have 4 ordered lists: waiting, pending, scheduled, and dead.

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.cr

Constant Summary

Log = ::Log.for(self)

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String) #

Instance Method Detail

def ==(other : self) : Bool #
Description copied from class Reference

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


def backend : Mosquito::Backend #

def backend=(backend : Mosquito::Backend) #

def banish(job_run : JobRun) #

def config_key : String #

def dequeue : JobRun | Nil #

def dequeue_scheduled : Array(JobRun) #

def empty? : Bool #

def enqueue(job_run : JobRun, in interval : Time::Span) : JobRun #

def enqueue(job_run : JobRun, at execute_time : Time) : JobRun #

def enqueue(job_run : JobRun) : JobRun #

def flush #

def forget(job_run : JobRun) #

def name : String #

def reschedule(job_run : JobRun, execution_time) #

def size(*, include_dead : Bool = true) : Int64 #