[Update] Add task timeout #1
|
@ -13,7 +13,7 @@ type Instance struct {
|
||||||
Server *asynq.ServeMux
|
Server *asynq.ServeMux
|
||||||
Scheduler *asynq.Scheduler
|
Scheduler *asynq.Scheduler
|
||||||
|
|
||||||
Configs Config
|
Config Config
|
||||||
}
|
}
|
||||||
|
|
||||||
var instance Instance
|
var instance Instance
|
||||||
|
@ -31,7 +31,7 @@ func NewInstance(cfg Config) Instance {
|
||||||
instance.Server = initServer(redisConn, cfg)
|
instance.Server = initServer(redisConn, cfg)
|
||||||
instance.Scheduler = initScheduler(redisConn)
|
instance.Scheduler = initScheduler(redisConn)
|
||||||
instance.Client = initClient(redisConn)
|
instance.Client = initClient(redisConn)
|
||||||
instance.Configs = cfg
|
instance.Config = cfg
|
||||||
|
|
||||||
// Return instance
|
// Return instance
|
||||||
return instance
|
return instance
|
||||||
|
|
4
task.go
4
task.go
|
@ -28,8 +28,8 @@ func (i Instance) RunTask(typename string, payload []byte, priority string, retr
|
||||||
options = append(options, asynq.MaxRetry(retryTimes))
|
options = append(options, asynq.MaxRetry(retryTimes))
|
||||||
|
|
||||||
// Task timeout
|
// Task timeout
|
||||||
if i.Configs.TaskTimeout != 0 {
|
if i.Config.TaskTimeout != 0 {
|
||||||
options = append(options, asynq.Timeout(i.Configs.TaskTimeout))
|
options = append(options, asynq.Timeout(i.Config.TaskTimeout))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enqueue task
|
// Enqueue task
|
||||||
|
|
Loading…
Reference in New Issue