From 28dae0fdd35064971a91afb6efec9256be27e0bf Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Mon, 2 Dec 2019 06:55:04 -0800 Subject: [PATCH] Add task types specific to each queue --- asynq.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/asynq.go b/asynq.go index 3d09463..ad99164 100644 --- a/asynq.go +++ b/asynq.go @@ -71,3 +71,49 @@ type Stats struct { Dead int Timestamp time.Time } + +// EnqueuedTask is a task in a queue and is ready to be processed. +// This is read only and used for inspection purpose. +type EnqueuedTask struct { + ID uuid.UUID + Type string + Payload map[string]interface{} +} + +// InProgressTask is a task that's currently being processed. +// This is read only and used for inspection purpose. +type InProgressTask struct { + ID uuid.UUID + Type string + Payload map[string]interface{} +} + +// ScheduledTask is a task that's scheduled to be processed in the future. +// This is read only and used for inspection purpose. +type ScheduledTask struct { + ID uuid.UUID + Type string + Payload map[string]interface{} + ProcessAt time.Time +} + +// RetryTask is a task that's in retry queue because worker failed to process the task. +// This is read only and used for inspection purpose. +type RetryTask struct { + ID uuid.UUID + Type string + Payload map[string]interface{} + // TODO(hibiken): add LastRetry time.Time + NextRetry time.Time + ErrorMsg string +} + +// DeadTask is a task in that has exhausted all retries. +// This is read only and used for inspection purpose. +type DeadTask struct { + ID uuid.UUID + Type string + Payload map[string]interface{} + // TODO(hibiken): add LastRetry time.Time + ErrorMsg string +}