diff --git a/CHANGELOG.md b/CHANGELOG.md index 918f22c..3825c8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 710ed78..6682310 100644 --- a/README.md +++ b/README.md @@ -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) } ``` diff --git a/doc.go b/doc.go index dfced06..ab8a51b 100644 --- a/doc.go +++ b/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