mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-10 11:31:58 +08:00
Invoke error handler when ctx.Done channel is closed
This commit is contained in:
parent
8d43fe407a
commit
007fac8055
@ -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:
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user