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 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.crConstructors
Instance Method Summary
-
#==(other : self) : Bool
Returns
true
if this reference is the same as other. - #backend : Mosquito::Backend
- #backend=(backend : Mosquito::Backend)
- #banish(task : Task)
- #config_key : String
- #dequeue : Task | Nil
- #dequeue_scheduled : Array(Task)
- #empty? : Bool
- #enqueue(task : Task, in interval : Time::Span) : Task
- #enqueue(task : Task, at execute_time : Time) : Task
- #enqueue(task : Task) : Task
- #flush
- #forget(task : Task)
-
#length : Int64
DEPRECATED see #size
- #name : String
- #reschedule(task : Task, execution_time)
- #size : 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?
.