2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-11-10 11:31:58 +08:00

[ci skip] Minor readme update

This commit is contained in:
Ken Hibino 2020-03-03 21:37:28 -08:00
parent b9e3cad7a7
commit 25992c2781

View File

@ -22,7 +22,9 @@ First, make sure you are running a Redis server locally.
$ redis-server $ redis-server
``` ```
To create and schedule tasks, use `Client` and provide a task and when to enqueue the task. Scheduled tasks will be stored in Redis and will be enqueued at the specified time. To create and schedule tasks, use `Client` and provide a task and when to enqueue the task.
A task will be processed by a background worker as soon as the task gets enqueued.
Scheduled tasks will be stored in Redis and will be enqueued at the specified time.
```go ```go
func main() { func main() {
@ -32,20 +34,19 @@ func main() {
client := asynq.NewClient(r) client := asynq.NewClient(r)
// Create a task with task type and payload // Create a task with task type and payload.
t1 := asynq.NewTask("email:signup", map[string]interface{}{"user_id": 42}) t1 := asynq.NewTask("email:signup", map[string]interface{}{"user_id": 42})
t2 := asynq.NewTask("email:reminder", map[string]interface{}{"user_id": 42}) t2 := asynq.NewTask("email:reminder", map[string]interface{}{"user_id": 42})
// Enqueue immediately // Enqueue immediately.
err := client.Enqueue(t1) err := client.Enqueue(t1)
// Enqueue 24 hrs later // Enqueue 24 hrs later.
err = client.EnqueueIn(24*time.Hour, t2) err = client.EnqueueIn(24*time.Hour, t2)
// Enqueue at specified time. // Enqueue at specific time.
target := time.Date(2020, time.March, 6, 10, 0, 0, 0, time.UTC) err = client.EnqueueAt(time.Date(2020, time.March, 6, 10, 0, 0, 0, time.UTC), t2)
err = client.EnqueueAt(target, t2)
// Pass vararg options to specify processing behavior for the given task. // Pass vararg options to specify processing behavior for the given task.
// //