mirror of
https://github.com/hibiken/asynq.git
synced 2025-04-22 08:40:22 +08:00
Change TaskMessage Timeout and Deadline to int
* This change breaks existing tasks in Redis
This commit is contained in:
parent
825b29b7f3
commit
7fddba8f10
@ -80,6 +80,8 @@ func NewTaskMessage(taskType string, payload map[string]interface{}) *base.TaskM
|
|||||||
Queue: base.DefaultQueueName,
|
Queue: base.DefaultQueueName,
|
||||||
Retry: 25,
|
Retry: 25,
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
|
Timeout: 1800, // default timeout of 30 mins
|
||||||
|
Deadline: 0, // no deadline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,18 +89,20 @@ type TaskMessage struct {
|
|||||||
// ErrorMsg holds the error message from the last failure.
|
// ErrorMsg holds the error message from the last failure.
|
||||||
ErrorMsg string
|
ErrorMsg string
|
||||||
|
|
||||||
// Timeout specifies how long a task may run.
|
// Timeout specifies timeout in seconds.
|
||||||
// The string value should be compatible with time.Duration.ParseDuration.
|
// If task processing doesn't complete within the timeout, the task will be retried
|
||||||
|
// if retry count is remaining. Otherwise it will be moved to the dead queue.
|
||||||
//
|
//
|
||||||
// Zero means no limit.
|
// Use zero to indicate no timeout.
|
||||||
Timeout string
|
Timeout int
|
||||||
|
|
||||||
// Deadline specifies the deadline for the task.
|
// Deadline specifies the deadline for the task in Unix time,
|
||||||
// Task won't be processed if it exceeded its deadline.
|
// the number of seconds elapsed since January 1, 1970 UTC.
|
||||||
// The string shoulbe be in RFC3339 format.
|
// If task processing doesn't complete before the deadline, the task will be retried
|
||||||
|
// if retry count is remaining. Otherwise it will be moved to the dead queue.
|
||||||
//
|
//
|
||||||
// time.Time's zero value means no deadline.
|
// Use zero to indicate no deadline.
|
||||||
Deadline string
|
Deadline int
|
||||||
|
|
||||||
// UniqueKey holds the redis key used for uniqueness lock for this task.
|
// UniqueKey holds the redis key used for uniqueness lock for this task.
|
||||||
//
|
//
|
||||||
|
@ -121,7 +121,8 @@ func TestMessageEncoding(t *testing.T) {
|
|||||||
Queue: "default",
|
Queue: "default",
|
||||||
Retry: 10,
|
Retry: 10,
|
||||||
Retried: 0,
|
Retried: 0,
|
||||||
Timeout: "0",
|
Timeout: 1800,
|
||||||
|
Deadline: 1692311100,
|
||||||
},
|
},
|
||||||
out: &TaskMessage{
|
out: &TaskMessage{
|
||||||
Type: "task1",
|
Type: "task1",
|
||||||
@ -130,7 +131,8 @@ func TestMessageEncoding(t *testing.T) {
|
|||||||
Queue: "default",
|
Queue: "default",
|
||||||
Retry: 10,
|
Retry: 10,
|
||||||
Retried: 0,
|
Retried: 0,
|
||||||
Timeout: "0",
|
Timeout: 1800,
|
||||||
|
Deadline: 1692311100,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user