Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <[email protected]>
  • Loading branch information
kmrmt committed Sep 6, 2024
1 parent bb06ded commit b1c53f4
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions internal/backoff/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (b *backoff) Do(

dctx, cancel := context.WithDeadline(sctx, time.Now().Add(b.backoffTimeLimit))
defer cancel()
for cnt := 1; cnt <= b.maxRetryCount; cnt++ {
for cnt := 0; cnt < b.maxRetryCount; cnt++ {
select {
case <-dctx.Done():
switch dctx.Err() {
Expand Down Expand Up @@ -185,21 +185,19 @@ func (b *backoff) Do(
} else {
dur *= b.backoffFactor
jdur = b.addJitter(dur)
if cnt >= b.maxRetryCount {
select {
case <-dctx.Done():
switch dctx.Err() {
case context.DeadlineExceeded:
log.Debugf("[backoff]\tfor: "+name+",\tDeadline Exceeded\terror: %v", err.Error())
return nil, errors.ErrBackoffTimeout(err)
case context.Canceled:
log.Debugf("[backoff]\tfor: "+name+",\tCanceled\terror: %v", err.Error())
return nil, err
default:
return nil, errors.Join(dctx.Err(), err)
}
select {
case <-dctx.Done():
switch dctx.Err() {
case context.DeadlineExceeded:
log.Debugf("[backoff]\tfor: "+name+",\tDeadline Exceeded\terror: %v", err.Error())
return nil, errors.ErrBackoffTimeout(err)
case context.Canceled:
log.Debugf("[backoff]\tfor: "+name+",\tCanceled\terror: %v", err.Error())
return nil, err
default:
return nil, errors.Join(dctx.Err(), err)

Check warning on line 198 in internal/backoff/backoff.go

View check run for this annotation

Codecov / codecov/patch

internal/backoff/backoff.go#L189-L198

Added lines #L189 - L198 were not covered by tests
}
default:
}
}
}
Expand Down

0 comments on commit b1c53f4

Please sign in to comment.