class Mosquito::Queue

Overview

A named Queue.

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

A task is represented in a queue by its id.

A task flows through the queues in this manner:

 Time=0: Task does not exist yet, lists are empty

   Waiting  Pending  Scheduled    Dead

 ---------------------------------
 Time=1: Task is enqueued

   Waiting  Pending  Scheduled    Dead
    Task#1

 ---------------------------------
 Time=2: Task begins running. Task is moved to pending and executed

   Waiting  Pending  Scheduled    Dead
             Task#1

 ---------------------------------
 Time=3: Tasks are Enqueued.

   Waiting  Pending  Scheduled    Dead
    Task#2   Task#1
    Task#3

 ---------------------------------
 Time=4: Task succeeds, next task begins.

   Waiting  Pending  Scheduled    Dead
    Task#3   Task#2

 ---------------------------------
 Time=5: Task fails and is scheduled for later, next task begins.

   Waiting  Pending  Scheduled     Dead
             Task#3  t=7:Task#2

 ---------------------------------
 Time=6: Task succeeds. Nothing is executing.

   Waiting  Pending  Scheduled     Dead
                     t=7:Task#2

 ---------------------------------
 Time=7: Scheduled task is due and is moved to waiting. Nothing is executing.

   Waiting  Pending  Scheduled     Dead
    Task#2

 ---------------------------------
 Time=8: Task begins executing (for the second time).

   Waiting  Pending  Scheduled     Dead
             Task#2

 ---------------------------------
 Time=9: Task finished successfully. No more tasks present.

   Waiting  Pending  Scheduled     Dead

Defined in:

mosquito/queue.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String) #

[View source]

Instance Method Detail

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

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


[View source]
def backend : Mosquito::Backend #

[View source]
def backend=(backend : Mosquito::Backend) #

[View source]
def banish(task : Task) #

[View source]
def config_key : String #

[View source]
def dequeue : Task | Nil #

[View source]
def dequeue_scheduled : Array(Task) #

[View source]
def empty? : Bool #

[View source]
def enqueue(task : Task, in interval : Time::Span) : Task #

[View source]
def enqueue(task : Task, at execute_time : Time) : Task #

[View source]
def enqueue(task : Task) : Task #

[View source]
def flush #

[View source]
def forget(task : Task) #

[View source]
def length : Int64 #

DEPRECATED see #size


[View source]
def name : String #

[View source]
def reschedule(task : Task, execution_time) #

[View source]
def size : Int64 #

[View source]