Skip to content

Commit

Permalink
♻️ Resolve busy-loop on worker
Browse files Browse the repository at this point in the history
Signed-off-by: Rintaro Okamura <[email protected]>
  • Loading branch information
rinx committed Apr 20, 2020
1 parent 7017111 commit 58d9ed3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/worker/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ func (q *queue) pop(ctx context.Context, retry uint64) (JobFunc, error) {
return nil, errors.ErrQueueIsNotRunning()
}

if retry == 0 {
return nil, errors.ErrJobFuncIsNil()
}

select {
case <-ctx.Done():
return nil, ctx.Err()
Expand All @@ -144,6 +140,11 @@ func (q *queue) pop(ctx context.Context, retry uint64) (JobFunc, error) {
return job, nil
}
}

if retry <= 0 {
return nil, errors.ErrJobFuncIsNil()
}

retry--
return q.pop(ctx, retry)
}
Expand Down

0 comments on commit 58d9ed3

Please sign in to comment.