mirror of
https://github.com/hibiken/asynq.git
synced 2025-04-22 00:30:17 +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(),
|
ID: xid.New(),
|
||||||
Type: task.Type,
|
Type: task.Type,
|
||||||
Payload: task.Payload,
|
Payload: task.Payload,
|
||||||
Queue: "default",
|
Priority: base.PriorityDefault,
|
||||||
Retry: opt.retry,
|
Retry: opt.retry,
|
||||||
}
|
}
|
||||||
return c.enqueue(msg, processAt)
|
return c.enqueue(msg, processAt)
|
||||||
|
@ -33,7 +33,7 @@ func TestClient(t *testing.T) {
|
|||||||
Type: task.Type,
|
Type: task.Type,
|
||||||
Payload: task.Payload,
|
Payload: task.Payload,
|
||||||
Retry: defaultMaxRetry,
|
Retry: defaultMaxRetry,
|
||||||
Queue: "default",
|
Priority: base.PriorityDefault,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantScheduled: nil, // db is flushed in setup so zset does not exist hence nil
|
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,
|
Type: task.Type,
|
||||||
Payload: task.Payload,
|
Payload: task.Payload,
|
||||||
Retry: defaultMaxRetry,
|
Retry: defaultMaxRetry,
|
||||||
Queue: "default",
|
Priority: base.PriorityDefault,
|
||||||
},
|
},
|
||||||
Score: time.Now().Add(2 * time.Hour).Unix(),
|
Score: time.Now().Add(2 * time.Hour).Unix(),
|
||||||
},
|
},
|
||||||
@ -68,7 +68,7 @@ func TestClient(t *testing.T) {
|
|||||||
Type: task.Type,
|
Type: task.Type,
|
||||||
Payload: task.Payload,
|
Payload: task.Payload,
|
||||||
Retry: 3,
|
Retry: 3,
|
||||||
Queue: "default",
|
Priority: base.PriorityDefault,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantScheduled: nil, // db is flushed in setup so zset does not exist hence nil
|
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,
|
Type: task.Type,
|
||||||
Payload: task.Payload,
|
Payload: task.Payload,
|
||||||
Retry: 0, // Retry count should be set to zero
|
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
|
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,
|
Type: task.Type,
|
||||||
Payload: task.Payload,
|
Payload: task.Payload,
|
||||||
Retry: 10, // Last option takes precedence
|
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
|
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{
|
return &base.TaskMessage{
|
||||||
ID: xid.New(),
|
ID: xid.New(),
|
||||||
Type: taskType,
|
Type: taskType,
|
||||||
Queue: "default",
|
Priority: base.PriorityDefault,
|
||||||
Retry: 25,
|
Retry: 25,
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,8 @@ type TaskMessage struct {
|
|||||||
// ID is a unique identifier for each task.
|
// ID is a unique identifier for each task.
|
||||||
ID xid.ID
|
ID xid.ID
|
||||||
|
|
||||||
// Queue is a name this message should be enqueued to.
|
// Priority is the priority of this task.
|
||||||
Queue string
|
Priority Priority
|
||||||
|
|
||||||
// Retry is the max number of retry for this task.
|
// Retry is the max number of retry for this task.
|
||||||
Retry int
|
Retry int
|
||||||
|
@ -42,7 +42,7 @@ func (r *RDB) Enqueue(msg *base.TaskMessage) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
qname := base.QueuePrefix + msg.Queue
|
qname := base.QueueKey(msg.Priority)
|
||||||
return r.client.LPush(qname, string(bytes)).Err()
|
return r.client.LPush(qname, string(bytes)).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user