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

allow cancel without retry

This commit is contained in:
thedmdim 2024-12-16 21:30:26 +04:00
parent 489e21920b
commit 35edb0281b

View File

@ -336,15 +336,18 @@ func (p *processor) handleFailedMessage(ctx context.Context, l *base.Lease, msg
p.errHandler.HandleError(ctx, NewTask(msg.Type, msg.Payload), err) p.errHandler.HandleError(ctx, NewTask(msg.Type, msg.Payload), err)
} }
switch { switch {
case errors.Is(err, RevokeTask): case errors.Is(err, RevokeTask):
p.logger.Warnf("revoke task id=%s", msg.ID) p.logger.Warnf("Revoke task id=%s", msg.ID)
p.markAsDone(l, msg) p.markAsDone(l, msg)
case msg.Retried >= msg.Retry || errors.Is(err, SkipRetry): case ctx.Err() == context.Canceled || errors.Is(err, SkipRetry):
p.logger.Warnf("Retry exhausted for task id=%s", msg.ID) p.logger.Warnf("Task canceled, skipping retry for id=%s", msg.ID)
p.archive(l, msg, err) p.archive(l, msg, err)
default: case msg.Retried >= msg.Retry:
p.retry(l, msg, err, p.isFailureFunc(err)) p.logger.Warnf("Retry exhausted for task id=%s", msg.ID)
} p.archive(l, msg, err)
default:
p.retry(l, msg, err, p.isFailureFunc(err))
}
} }
func (p *processor) retry(l *base.Lease, msg *base.TaskMessage, e error, isFailure bool) { func (p *processor) retry(l *base.Lease, msg *base.TaskMessage, e error, isFailure bool) {