class Mosquito::Queue
- Mosquito::Queue
- Reference
- Object
Overview
A named Queue.
Named Queues exist in Redis 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.crConstant Summary
-
ID_PREFIX =
{"mosquito"}
-
QUEUES =
["waiting", "scheduled", "pending", "dead", "config"] of ::String
Constructors
Class Method Summary
Instance Method Summary
-
#==(other : self) : Bool
Returns
true
if this reference is the same as other. - #banish(task : Task)
- #config_q
- #dead_q
- #dequeue : Task | Nil
- #dequeue_scheduled : Array(Task)
- #empty? : Bool
- #enqueue(task : Task, in interval : Time::Span)
- #enqueue(task : Task, at execute_time : Time)
- #enqueue(task : Task)
- #flush
- #forget(task : Task)
-
#length : Int32
TODO does this make sense?
- #name : String
- #pending_q
-
#rate_limited? : Bool
Determines if a task needs to be throttled and not dequeued
- #redis_key(*parts)
- #reschedule(task : Task, execution_time)
- #scheduled_q
- #waiting_q
Constructor Detail
Class Method 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?
.