mirror of
https://github.com/hibiken/asynq.git
synced 2025-08-19 15:08:55 +08:00
Add enq command to asynqmon
This commit is contained in:
@@ -42,6 +42,7 @@ type ScheduledTask struct {
|
||||
Type string
|
||||
Payload map[string]interface{}
|
||||
ProcessAt time.Time
|
||||
Score int64
|
||||
}
|
||||
|
||||
// RetryTask is a task that's in retry queue because worker failed to process the task.
|
||||
@@ -55,6 +56,7 @@ type RetryTask struct {
|
||||
ErrorMsg string
|
||||
Retried int
|
||||
Retry int
|
||||
Score int64
|
||||
}
|
||||
|
||||
// DeadTask is a task in that has exhausted all retries.
|
||||
@@ -65,6 +67,7 @@ type DeadTask struct {
|
||||
Payload map[string]interface{}
|
||||
LastFailedAt time.Time
|
||||
ErrorMsg string
|
||||
Score int64
|
||||
}
|
||||
|
||||
// CurrentStats returns a current state of the queues.
|
||||
@@ -158,6 +161,7 @@ func (r *RDB) ListScheduled() ([]*ScheduledTask, error) {
|
||||
Type: msg.Type,
|
||||
Payload: msg.Payload,
|
||||
ProcessAt: processAt,
|
||||
Score: int64(z.Score),
|
||||
})
|
||||
}
|
||||
return tasks, nil
|
||||
@@ -190,6 +194,7 @@ func (r *RDB) ListRetry() ([]*RetryTask, error) {
|
||||
Retry: msg.Retry,
|
||||
Retried: msg.Retried,
|
||||
ProcessAt: processAt,
|
||||
Score: int64(z.Score),
|
||||
})
|
||||
}
|
||||
return tasks, nil
|
||||
@@ -219,6 +224,7 @@ func (r *RDB) ListDead() ([]*DeadTask, error) {
|
||||
Payload: msg.Payload,
|
||||
ErrorMsg: msg.ErrorMsg,
|
||||
LastFailedAt: lastFailedAt,
|
||||
Score: int64(z.Score),
|
||||
})
|
||||
}
|
||||
return tasks, nil
|
||||
|
@@ -249,8 +249,8 @@ func TestListScheduled(t *testing.T) {
|
||||
m2 := randomTask("reindex", "default", nil)
|
||||
p1 := time.Now().Add(30 * time.Minute)
|
||||
p2 := time.Now().Add(24 * time.Hour)
|
||||
t1 := &ScheduledTask{ID: m1.ID, Type: m1.Type, Payload: m1.Payload, ProcessAt: p1}
|
||||
t2 := &ScheduledTask{ID: m2.ID, Type: m2.Type, Payload: m2.Payload, ProcessAt: p2}
|
||||
t1 := &ScheduledTask{ID: m1.ID, Type: m1.Type, Payload: m1.Payload, ProcessAt: p1, Score: p1.Unix()}
|
||||
t2 := &ScheduledTask{ID: m2.ID, Type: m2.Type, Payload: m2.Payload, ProcessAt: p2, Score: p2.Unix()}
|
||||
|
||||
type scheduledEntry struct {
|
||||
msg *TaskMessage
|
||||
@@ -330,9 +330,11 @@ func TestListRetry(t *testing.T) {
|
||||
p1 := time.Now().Add(5 * time.Minute)
|
||||
p2 := time.Now().Add(24 * time.Hour)
|
||||
t1 := &RetryTask{ID: m1.ID, Type: m1.Type, Payload: m1.Payload,
|
||||
ProcessAt: p1, ErrorMsg: m1.ErrorMsg, Retried: m1.Retried, Retry: m1.Retry}
|
||||
ProcessAt: p1, ErrorMsg: m1.ErrorMsg, Retried: m1.Retried,
|
||||
Retry: m1.Retry, Score: p1.Unix()}
|
||||
t2 := &RetryTask{ID: m2.ID, Type: m2.Type, Payload: m2.Payload,
|
||||
ProcessAt: p2, ErrorMsg: m2.ErrorMsg, Retried: m2.Retried, Retry: m2.Retry}
|
||||
ProcessAt: p2, ErrorMsg: m2.ErrorMsg, Retried: m2.Retried,
|
||||
Retry: m2.Retry, Score: p2.Unix()}
|
||||
|
||||
type retryEntry struct {
|
||||
msg *TaskMessage
|
||||
@@ -407,8 +409,10 @@ func TestListDead(t *testing.T) {
|
||||
}
|
||||
f1 := time.Now().Add(-5 * time.Minute)
|
||||
f2 := time.Now().Add(-24 * time.Hour)
|
||||
t1 := &DeadTask{ID: m1.ID, Type: m1.Type, Payload: m1.Payload, LastFailedAt: f1, ErrorMsg: m1.ErrorMsg}
|
||||
t2 := &DeadTask{ID: m2.ID, Type: m2.Type, Payload: m2.Payload, LastFailedAt: f2, ErrorMsg: m2.ErrorMsg}
|
||||
t1 := &DeadTask{ID: m1.ID, Type: m1.Type, Payload: m1.Payload,
|
||||
LastFailedAt: f1, ErrorMsg: m1.ErrorMsg, Score: f1.Unix()}
|
||||
t2 := &DeadTask{ID: m2.ID, Type: m2.Type, Payload: m2.Payload,
|
||||
LastFailedAt: f2, ErrorMsg: m2.ErrorMsg, Score: f2.Unix()}
|
||||
|
||||
type deadEntry struct {
|
||||
msg *TaskMessage
|
||||
|
Reference in New Issue
Block a user