Make Task type immutable

This change makes it impossible to mutate payload within Handler or
RetryDelayFunc.
This commit is contained in:
Ken Hibino
2020-01-04 13:13:46 -08:00
parent 899566e661
commit f3a23b9b12
14 changed files with 92 additions and 345 deletions

9
doc.go
View File

@@ -9,12 +9,11 @@ The Client is used to register a task to be processed at the specified time.
client := asynq.NewClient(redis)
t := asynq.Task{
Type: "send_email",
Payload: map[string]interface{}{"user_id": 42},
}
t := asynq.NewTask(
"send_email",
map[string]interface{}{"user_id": 42})
err := client.Schedule(&t, time.Now().Add(time.Minute))
err := client.Schedule(t, time.Now().Add(time.Minute))
The Background is used to run the background task processing with a given
handler.