mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-25 23:32:17 +08:00
Add Group field to TaskInfo struct
This commit is contained in:
parent
01eeb8756e
commit
45ed560708
9
asynq.go
9
asynq.go
@ -98,6 +98,14 @@ type TaskInfo struct {
|
||||
// Deadline is the deadline for the task, zero value if not specified.
|
||||
Deadline time.Time
|
||||
|
||||
// Group is the name of the group in which the task belongs.
|
||||
//
|
||||
// Tasks in the same queue can be grouped together by Group name and will be aggregated into one task
|
||||
// by a Server processing the queue.
|
||||
//
|
||||
// Empty string (default) indicates task does not belong to any groups, and no aggregation will be applied to the task.
|
||||
Group string
|
||||
|
||||
// NextProcessAt is the time the task is scheduled to be processed,
|
||||
// zero if not applicable.
|
||||
NextProcessAt time.Time
|
||||
@ -140,6 +148,7 @@ func newTaskInfo(msg *base.TaskMessage, state base.TaskState, nextProcessAt time
|
||||
MaxRetry: msg.Retry,
|
||||
Retried: msg.Retried,
|
||||
LastErr: msg.ErrorMsg,
|
||||
Group: msg.GroupKey,
|
||||
Timeout: time.Duration(msg.Timeout) * time.Second,
|
||||
Deadline: fromUnixTimeOrZero(msg.Deadline),
|
||||
Retention: time.Duration(msg.Retention) * time.Second,
|
||||
|
@ -503,6 +503,7 @@ func TestClientEnqueueWithGroupOption(t *testing.T) {
|
||||
},
|
||||
wantInfo: &TaskInfo{
|
||||
Queue: "default",
|
||||
Group: "mygroup",
|
||||
Type: task.Type(),
|
||||
Payload: task.Payload(),
|
||||
State: TaskStateAggregating,
|
||||
@ -548,6 +549,7 @@ func TestClientEnqueueWithGroupOption(t *testing.T) {
|
||||
},
|
||||
wantInfo: &TaskInfo{
|
||||
Queue: "default",
|
||||
Group: "mygroup",
|
||||
Type: task.Type(),
|
||||
Payload: task.Payload(),
|
||||
State: TaskStateScheduled,
|
||||
|
Loading…
Reference in New Issue
Block a user