mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-26 07:42:17 +08:00
Rename Workers to Launcher
This commit is contained in:
parent
4485b6e3a9
commit
89c54fb47d
14
asynq.go
14
asynq.go
@ -102,8 +102,8 @@ func (c *Client) enqueue(msg *taskMessage, executeAt time.Time) error {
|
|||||||
|
|
||||||
//-------------------- Workers --------------------
|
//-------------------- Workers --------------------
|
||||||
|
|
||||||
// Workers represents a pool of workers.
|
// Launcher starts the manager and poller.
|
||||||
type Workers struct {
|
type Launcher struct {
|
||||||
rdb *redis.Client
|
rdb *redis.Client
|
||||||
|
|
||||||
// poolTokens is a counting semaphore to ensure the number of active workers
|
// poolTokens is a counting semaphore to ensure the number of active workers
|
||||||
@ -116,8 +116,8 @@ type Workers struct {
|
|||||||
poller *poller
|
poller *poller
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWorkers creates and returns a new Workers.
|
// NewLauncher creates and returns a new Launcher.
|
||||||
func NewWorkers(poolSize int, opt *RedisOpt) *Workers {
|
func NewLauncher(poolSize int, opt *RedisOpt) *Launcher {
|
||||||
rdb := redis.NewClient(&redis.Options{Addr: opt.Addr, Password: opt.Password})
|
rdb := redis.NewClient(&redis.Options{Addr: opt.Addr, Password: opt.Password})
|
||||||
poller := &poller{
|
poller := &poller{
|
||||||
rdb: rdb,
|
rdb: rdb,
|
||||||
@ -125,7 +125,7 @@ func NewWorkers(poolSize int, opt *RedisOpt) *Workers {
|
|||||||
avgInterval: 5 * time.Second,
|
avgInterval: 5 * time.Second,
|
||||||
zsets: []string{scheduled, retry},
|
zsets: []string{scheduled, retry},
|
||||||
}
|
}
|
||||||
return &Workers{
|
return &Launcher{
|
||||||
rdb: rdb,
|
rdb: rdb,
|
||||||
poller: poller,
|
poller: poller,
|
||||||
poolTokens: make(chan struct{}, poolSize),
|
poolTokens: make(chan struct{}, poolSize),
|
||||||
@ -135,8 +135,8 @@ func NewWorkers(poolSize int, opt *RedisOpt) *Workers {
|
|||||||
// TaskHandler handles a given task and report any error.
|
// TaskHandler handles a given task and report any error.
|
||||||
type TaskHandler func(*Task) error
|
type TaskHandler func(*Task) error
|
||||||
|
|
||||||
// Run starts the workers and scheduler with a given handler.
|
// Start starts the workers and scheduler with a given handler.
|
||||||
func (w *Workers) Run(handler TaskHandler) {
|
func (w *Launcher) Start(handler TaskHandler) {
|
||||||
if w.running {
|
if w.running {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user