mirror of
https://github.com/hibiken/asynq.git
synced 2025-04-21 16:20:18 +08:00
Remove Queue field and Priority field to base.TaskMessage
This commit is contained in:
parent
31a18d783e
commit
2e95166f39
@ -79,7 +79,7 @@ func (c *Client) Process(task *Task, processAt time.Time, opts ...Option) error
|
||||
ID: xid.New(),
|
||||
Type: task.Type,
|
||||
Payload: task.Payload,
|
||||
Queue: "default",
|
||||
Priority: base.PriorityDefault,
|
||||
Retry: opt.retry,
|
||||
}
|
||||
return c.enqueue(msg, processAt)
|
||||
|
@ -33,7 +33,7 @@ func TestClient(t *testing.T) {
|
||||
Type: task.Type,
|
||||
Payload: task.Payload,
|
||||
Retry: defaultMaxRetry,
|
||||
Queue: "default",
|
||||
Priority: base.PriorityDefault,
|
||||
},
|
||||
},
|
||||
wantScheduled: nil, // db is flushed in setup so zset does not exist hence nil
|
||||
@ -50,7 +50,7 @@ func TestClient(t *testing.T) {
|
||||
Type: task.Type,
|
||||
Payload: task.Payload,
|
||||
Retry: defaultMaxRetry,
|
||||
Queue: "default",
|
||||
Priority: base.PriorityDefault,
|
||||
},
|
||||
Score: time.Now().Add(2 * time.Hour).Unix(),
|
||||
},
|
||||
@ -68,7 +68,7 @@ func TestClient(t *testing.T) {
|
||||
Type: task.Type,
|
||||
Payload: task.Payload,
|
||||
Retry: 3,
|
||||
Queue: "default",
|
||||
Priority: base.PriorityDefault,
|
||||
},
|
||||
},
|
||||
wantScheduled: nil, // db is flushed in setup so zset does not exist hence nil
|
||||
@ -85,7 +85,7 @@ func TestClient(t *testing.T) {
|
||||
Type: task.Type,
|
||||
Payload: task.Payload,
|
||||
Retry: 0, // Retry count should be set to zero
|
||||
Queue: "default",
|
||||
Priority: base.PriorityDefault,
|
||||
},
|
||||
},
|
||||
wantScheduled: nil, // db is flushed in setup so zset does not exist hence nil
|
||||
@ -103,7 +103,7 @@ func TestClient(t *testing.T) {
|
||||
Type: task.Type,
|
||||
Payload: task.Payload,
|
||||
Retry: 10, // Last option takes precedence
|
||||
Queue: "default",
|
||||
Priority: base.PriorityDefault,
|
||||
},
|
||||
},
|
||||
wantScheduled: nil, // db is flushed in setup so zset does not exist hence nil
|
||||
|
@ -45,7 +45,7 @@ func NewTaskMessage(taskType string, payload map[string]interface{}) *base.TaskM
|
||||
return &base.TaskMessage{
|
||||
ID: xid.New(),
|
||||
Type: taskType,
|
||||
Queue: "default",
|
||||
Priority: base.PriorityDefault,
|
||||
Retry: 25,
|
||||
Payload: payload,
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ type TaskMessage struct {
|
||||
// ID is a unique identifier for each task.
|
||||
ID xid.ID
|
||||
|
||||
// Queue is a name this message should be enqueued to.
|
||||
Queue string
|
||||
// Priority is the priority of this task.
|
||||
Priority Priority
|
||||
|
||||
// Retry is the max number of retry for this task.
|
||||
Retry int
|
||||
|
@ -42,7 +42,7 @@ func (r *RDB) Enqueue(msg *base.TaskMessage) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
qname := base.QueuePrefix + msg.Queue
|
||||
qname := base.QueueKey(msg.Priority)
|
||||
return r.client.LPush(qname, string(bytes)).Err()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user