mirror of
https://github.com/hibiken/asynq.git
synced 2025-01-13 00:13:39 +08:00
fix: avoid retry if MaxRetry zero
This commit is contained in:
parent
8c0d758eef
commit
1fe0d81544
@ -322,6 +322,12 @@ func (p *processor) markAsDone(l *base.Lease, msg *base.TaskMessage) {
|
||||
var SkipRetry = errors.New("skip retry for the task")
|
||||
|
||||
func (p *processor) handleFailedMessage(ctx context.Context, l *base.Lease, msg *base.TaskMessage, err error) {
|
||||
if msg.Retry == 0 {
|
||||
if errors.Is(err, SkipRetry) {
|
||||
p.markAsDone(l, msg)
|
||||
return
|
||||
}
|
||||
}
|
||||
if p.errHandler != nil {
|
||||
p.errHandler.HandleError(ctx, NewTask(msg.Type, msg.Payload), err)
|
||||
}
|
||||
@ -339,7 +345,7 @@ func (p *processor) handleFailedMessage(ctx context.Context, l *base.Lease, msg
|
||||
}
|
||||
|
||||
func (p *processor) retry(l *base.Lease, msg *base.TaskMessage, e error, isFailure bool) {
|
||||
if !l.IsValid() {
|
||||
if !l.IsValid() || msg.Retry == 0 {
|
||||
// If lease is not valid, do not write to redis; Let recoverer take care of it.
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user