Skip to content

Commit

Permalink
add check context cancel
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <[email protected]>
  • Loading branch information
kmrmt committed Sep 5, 2024
1 parent b17cc73 commit e8bcb40
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/backoff/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,22 @@ func (b *backoff) Do(
jdur = b.addJitter(dur)
}
}

}
}
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)

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

View check run for this annotation

Codecov / codecov/patch

internal/backoff/backoff.go#L196-L198

Added lines #L196 - L198 were not covered by tests
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 203 in internal/backoff/backoff.go

View check run for this annotation

Codecov / codecov/patch

internal/backoff/backoff.go#L202-L203

Added lines #L202 - L203 were not covered by tests
}
default:
}
return res, err
}
Expand Down

0 comments on commit e8bcb40

Please sign in to comment.