2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-25 23:32:17 +08:00

Invoke error handler when ctx.Done channel is closed

This commit is contained in:
Ken Hibino 2020-07-04 06:31:56 -07:00
parent 8d43fe407a
commit 007fac8055
2 changed files with 4 additions and 1 deletions

View File

@ -203,6 +203,9 @@ func (p *processor) exec() {
return return
case <-ctx.Done(): case <-ctx.Done():
p.logger.Debugf("Retrying task. task id=%s", msg.ID) // TODO: Improve this log message and above p.logger.Debugf("Retrying task. task id=%s", msg.ID) // TODO: Improve this log message and above
if p.errHandler != nil {
p.errHandler.HandleError(ctx, task, ctx.Err())
}
p.retryOrKill(ctx, msg, ctx.Err()) p.retryOrKill(ctx, msg, ctx.Err())
return return
case resErr := <-resCh: case resErr := <-resCh:

View File

@ -125,7 +125,7 @@ type Config struct {
ShutdownTimeout time.Duration ShutdownTimeout time.Duration
} }
// An ErrorHandler handles errors returned by the task handler. // An ErrorHandler handles an error occured during task processing.
type ErrorHandler interface { type ErrorHandler interface {
HandleError(ctx context.Context, task *Task, err error) HandleError(ctx context.Context, task *Task, err error)
} }