Skip to content

Commit

Permalink
retry: Reduce nil checks for errors
Browse files Browse the repository at this point in the history
Before, with `Timeout >0`, we had to check errors for `nil` because we
were using a deadline context that might have cancelled before the retry
function completed with an error, but since we now pass `ctx` as-is,
this is no longer necessary.
  • Loading branch information
lippserd committed Apr 3, 2024
1 parent c7f5ed9 commit fefa5f8
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions pkg/retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,11 @@ func WithBackoff(
select {
case <-time.After(b(attempt)):
case <-timeout:
if err != nil {
err = errors.Wrap(err, "retry deadline exceeded")
} else {
err = errors.New("retry deadline exceeded")
}
err = errors.Wrap(err, "retry deadline exceeded")

return
case <-ctx.Done():
if err == nil {
err = ctx.Err()
}
err = errors.Wrap(err, "can't retry")
err = errors.Wrap(err, ctx.Err().Error())

return
}
Expand Down

0 comments on commit fefa5f8

Please sign in to comment.