mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-10 11:31:58 +08:00
Update docs with new APIs
This commit is contained in:
parent
b086e88a47
commit
24da281aa7
@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- `Background` type is renamed to `Server`.
|
||||
- To upgrade from the previous version, Update `NewBackground` to `NewServer` and pass `Config` by value.
|
||||
- New `Server` type exposes `Start`, `Stop`, and `Quiet` as well as `Run`.
|
||||
- CLI is renamed to `asynq`.
|
||||
- To upgrade to the latest version run `go get -u github.com/hibiken/tools/asynq`
|
||||
- The `ps` command in CLI is renamed to `servers`
|
||||
|
||||
## [0.7.1] - 2020-04-05
|
||||
|
||||
### Fixed
|
||||
|
@ -161,8 +161,8 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
Next, create a binary to process these tasks in the background.
|
||||
To start the background workers, use [`Background`](https://pkg.go.dev/github.com/hibiken/asynq?tab=doc#Background) and provide your [`Handler`](https://pkg.go.dev/github.com/hibiken/asynq?tab=doc#Handler) to process the tasks.
|
||||
Next, create a work server binary to process these tasks in the background.
|
||||
To start the background workers, use [`Server`](https://pkg.go.dev/github.com/hibiken/asynq?tab=doc#Server) and provide your [`Handler`](https://pkg.go.dev/github.com/hibiken/asynq?tab=doc#Handler) to process the tasks.
|
||||
|
||||
You can optionally use [`ServeMux`](https://pkg.go.dev/github.com/hibiken/asynq?tab=doc#ServeMux) to create a handler, just as you would with [`"net/http"`](https://golang.org/pkg/net/http/) Handler.
|
||||
|
||||
@ -179,7 +179,7 @@ const redisAddr = "127.0.0.1:6379"
|
||||
func main() {
|
||||
r := &asynq.RedisClientOpt{Addr: redisAddr}
|
||||
|
||||
bg := asynq.NewBackground(r, &asynq.Config{
|
||||
srv := asynq.NewServer(r, asynq.Config{
|
||||
// Specify how many concurrent workers to use
|
||||
Concurrency: 10,
|
||||
// Optionally specify multiple queues with different priority.
|
||||
@ -197,7 +197,7 @@ func main() {
|
||||
mux.HandleFunc(tasks.ImageProcessing, tasks.HandleImageProcessingTask)
|
||||
// ...register other handlers...
|
||||
|
||||
bg.Run(mux)
|
||||
srv.Run(mux)
|
||||
}
|
||||
```
|
||||
|
||||
|
6
doc.go
6
doc.go
@ -30,13 +30,13 @@ Task is created with two parameters: its type and payload.
|
||||
// Schedule the task to be processed in one minute.
|
||||
err = client.EnqueueIn(time.Minute, t)
|
||||
|
||||
The Background is used to run the background task processing with a given
|
||||
The Server is used to run the background task processing with a given
|
||||
handler.
|
||||
bg := asynq.NewBackground(redis, &asynq.Config{
|
||||
srv := asynq.NewServer(redis, asynq.Config{
|
||||
Concurrency: 10,
|
||||
})
|
||||
|
||||
bg.Run(handler)
|
||||
srv.Run(handler)
|
||||
|
||||
Handler is an interface with one method ProcessTask which
|
||||
takes a task and returns an error. Handler should return nil if
|
||||
|
Loading…
Reference in New Issue
Block a user