Skip to content

Commit

Permalink
add check context cancel (#2596)
Browse files Browse the repository at this point in the history
* add check context cancel

Signed-off-by: Kosuke Morimoto <[email protected]>

* fix

Signed-off-by: Kosuke Morimoto <[email protected]>

* fix

Signed-off-by: Kosuke Morimoto <[email protected]>

* fix

Signed-off-by: Kosuke Morimoto <[email protected]>

* fix

Signed-off-by: Kosuke Morimoto <[email protected]>

* fix

Signed-off-by: Kosuke Morimoto <[email protected]>

* fix

Signed-off-by: Kosuke Morimoto <[email protected]>

* fix

Signed-off-by: Kosuke Morimoto <[email protected]>

* update deps

Signed-off-by: Kosuke Morimoto <[email protected]>

---------

Signed-off-by: Kosuke Morimoto <[email protected]>
Co-authored-by: Yusuke Kato <[email protected]>
  • Loading branch information
kmrmt and kpango authored Sep 12, 2024
1 parent aa4bbc0 commit 0e12419
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions internal/backoff/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,22 @@ func (b *backoff) Do(
dur *= b.backoffFactor
jdur = b.addJitter(dur)
}
if cnt >= b.maxRetryCount-1 {
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)
}
default:
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion versions/GO_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.23.0
1.23.1

0 comments on commit 0e12419

Please sign in to comment.