2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-25 07:12:17 +08:00

Update readme

This commit is contained in:
Ken Hibino 2020-04-18 08:03:58 -07:00
parent bf542a781c
commit 74e5582cfc
2 changed files with 9 additions and 11 deletions

View File

@ -112,8 +112,8 @@ func HandleImageProcessingTask(ctx context.Context, t *asynq.Task) error {
} }
``` ```
In your web application code, import the above package and use [`Client`](https://pkg.go.dev/github.com/hibiken/asynq?tab=doc#Client) to enqueue tasks to the task queue. In your web application code, import the above package and use [`Client`](https://pkg.go.dev/github.com/hibiken/asynq?tab=doc#Client) to put tasks on the queue.
A task will be processed by a background worker as soon as the task gets enqueued. A task will be processed asynchronously 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. Scheduled tasks will be stored in Redis and will be enqueued at the specified time.
```go ```go
@ -129,7 +129,7 @@ import (
const redisAddr = "127.0.0.1:6379" const redisAddr = "127.0.0.1:6379"
func main() { func main() {
r := &asynq.RedisClientOpt{Addr: redisAddr} r := asynq.RedisClientOpt{Addr: redisAddr}
c := asynq.NewClient(r) c := asynq.NewClient(r)
// Example 1: Enqueue task to be processed immediately. // Example 1: Enqueue task to be processed immediately.
@ -151,7 +151,7 @@ func main() {
// Example 3: Pass options to tune task processing behavior. // Example 3: Pass options to tune task processing behavior.
// Options include MaxRetry, Queue, Timeout, Deadline, etc. // Options include MaxRetry, Queue, Timeout, Deadline, Unique etc.
t = tasks.NewImageProcessingTask("some/blobstore/url", "other/blobstore/url") t = tasks.NewImageProcessingTask("some/blobstore/url", "other/blobstore/url")
err = c.Enqueue(t, asynq.MaxRetry(10), asynq.Queue("critical"), asynq.Timeout(time.Minute)) err = c.Enqueue(t, asynq.MaxRetry(10), asynq.Queue("critical"), asynq.Timeout(time.Minute))
@ -177,7 +177,7 @@ import (
const redisAddr = "127.0.0.1:6379" const redisAddr = "127.0.0.1:6379"
func main() { func main() {
r := &asynq.RedisClientOpt{Addr: redisAddr} r := asynq.RedisClientOpt{Addr: redisAddr}
srv := asynq.NewServer(r, asynq.Config{ srv := asynq.NewServer(r, asynq.Config{
// Specify how many concurrent workers to use // Specify how many concurrent workers to use

View File

@ -8,7 +8,7 @@ Asynq CLI is a command line tool to monitor the tasks managed by `asynq` package
- [Quick Start](#quick-start) - [Quick Start](#quick-start)
- [Stats](#stats) - [Stats](#stats)
- [History](#history) - [History](#history)
- [Process Status](#process-status) - [Servers](#servers)
- [List](#list) - [List](#list)
- [Enqueue](#enqueue) - [Enqueue](#enqueue)
- [Delete](#delete) - [Delete](#delete)
@ -58,15 +58,13 @@ Example:
![Gif](/docs/assets/asynq_history.gif) ![Gif](/docs/assets/asynq_history.gif)
### Process Status ### Servers
PS (ProcessStatus) command shows the list of running worker processes. Servers command shows the list of running worker servers pulling tasks from the given redis instance.
Example: Example:
asynq ps asynq servers
![Gif](/docs/assets/asynq_ps.gif)
### List ### List