mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-27 00:02:19 +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 is the deadline for the task, zero value if not specified.
|
||||||
Deadline time.Time
|
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,
|
// NextProcessAt is the time the task is scheduled to be processed,
|
||||||
// zero if not applicable.
|
// zero if not applicable.
|
||||||
NextProcessAt time.Time
|
NextProcessAt time.Time
|
||||||
@ -140,6 +148,7 @@ func newTaskInfo(msg *base.TaskMessage, state base.TaskState, nextProcessAt time
|
|||||||
MaxRetry: msg.Retry,
|
MaxRetry: msg.Retry,
|
||||||
Retried: msg.Retried,
|
Retried: msg.Retried,
|
||||||
LastErr: msg.ErrorMsg,
|
LastErr: msg.ErrorMsg,
|
||||||
|
Group: msg.GroupKey,
|
||||||
Timeout: time.Duration(msg.Timeout) * time.Second,
|
Timeout: time.Duration(msg.Timeout) * time.Second,
|
||||||
Deadline: fromUnixTimeOrZero(msg.Deadline),
|
Deadline: fromUnixTimeOrZero(msg.Deadline),
|
||||||
Retention: time.Duration(msg.Retention) * time.Second,
|
Retention: time.Duration(msg.Retention) * time.Second,
|
||||||
|
@ -503,6 +503,7 @@ func TestClientEnqueueWithGroupOption(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantInfo: &TaskInfo{
|
wantInfo: &TaskInfo{
|
||||||
Queue: "default",
|
Queue: "default",
|
||||||
|
Group: "mygroup",
|
||||||
Type: task.Type(),
|
Type: task.Type(),
|
||||||
Payload: task.Payload(),
|
Payload: task.Payload(),
|
||||||
State: TaskStateAggregating,
|
State: TaskStateAggregating,
|
||||||
@ -548,6 +549,7 @@ func TestClientEnqueueWithGroupOption(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantInfo: &TaskInfo{
|
wantInfo: &TaskInfo{
|
||||||
Queue: "default",
|
Queue: "default",
|
||||||
|
Group: "mygroup",
|
||||||
Type: task.Type(),
|
Type: task.Type(),
|
||||||
Payload: task.Payload(),
|
Payload: task.Payload(),
|
||||||
State: TaskStateScheduled,
|
State: TaskStateScheduled,
|
||||||
|
Loading…
Reference in New Issue
Block a user