mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-26 07:42:17 +08:00
Fix recoverer to run task recovering logic every minute
This commit is contained in:
parent
d5e9f3b1bd
commit
ff6768f9bb
16
recoverer.go
16
recoverer.go
@ -65,14 +65,22 @@ func (r *recoverer) start(wg *sync.WaitGroup) {
|
||||
timer.Stop()
|
||||
return
|
||||
case <-timer.C:
|
||||
r.recover()
|
||||
timer.Reset(r.interval)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (r *recoverer) recover() {
|
||||
// Get all tasks which have expired 30 seconds ago or earlier.
|
||||
deadline := time.Now().Add(-30 * time.Second)
|
||||
msgs, err := r.broker.ListDeadlineExceeded(deadline, r.queues...)
|
||||
if err != nil {
|
||||
r.logger.Warn("recoverer: could not list deadline exceeded tasks")
|
||||
continue
|
||||
return
|
||||
}
|
||||
const errMsg = "deadline exceeded" // TODO: better error message
|
||||
const errMsg = "deadline exceeded"
|
||||
for _, msg := range msgs {
|
||||
if msg.Retried >= msg.Retry {
|
||||
r.archive(msg, errMsg)
|
||||
@ -80,10 +88,6 @@ func (r *recoverer) start(wg *sync.WaitGroup) {
|
||||
r.retry(msg, errMsg)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (r *recoverer) retry(msg *base.TaskMessage, errMsg string) {
|
||||
|
Loading…
Reference in New Issue
Block a user