update retry config
This commit is contained in:
parent
410f8fa765
commit
3bdd6ce7ff
|
@ -1,6 +1,10 @@
|
|||
package queue
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/hibiken/asynq"
|
||||
)
|
||||
|
||||
// Config ...
|
||||
type Config struct {
|
||||
|
@ -14,6 +18,7 @@ type Config struct {
|
|||
Priority ConfigPriority
|
||||
|
||||
TaskTimeout time.Duration
|
||||
RetryDelayFunc asynq.RetryDelayFunc
|
||||
}
|
||||
|
||||
// ConfigRedis ...
|
||||
|
|
13
instance.go
13
instance.go
|
@ -50,6 +50,13 @@ func initServer(redisConn asynq.RedisClientOpt, cfg Config) *asynq.ServeMux {
|
|||
cfg.Priority.Low = 1
|
||||
cfg.Priority.StrictMode = false
|
||||
}
|
||||
retryDelayFunc := cfg.RetryDelayFunc
|
||||
if retryDelayFunc == nil {
|
||||
// Default delay in 10s
|
||||
retryDelayFunc = func(n int, e error, t *asynq.Task) time.Duration {
|
||||
return 10 * time.Second
|
||||
}
|
||||
}
|
||||
|
||||
// Init server
|
||||
server := asynq.NewServer(redisConn, asynq.Config{
|
||||
|
@ -61,11 +68,7 @@ func initServer(redisConn asynq.RedisClientOpt, cfg Config) *asynq.ServeMux {
|
|||
},
|
||||
StrictPriority: cfg.Priority.StrictMode,
|
||||
|
||||
// TODO:
|
||||
// This is default option, retry after 10s, will add to config later
|
||||
RetryDelayFunc: func(n int, e error, t *asynq.Task) time.Duration {
|
||||
return 10 * time.Second
|
||||
},
|
||||
RetryDelayFunc: retryDelayFunc,
|
||||
})
|
||||
|
||||
// Init mux server
|
||||
|
|
Loading…
Reference in New Issue