Skip to content

Commit

Permalink
after backoff wait
Browse files Browse the repository at this point in the history
  • Loading branch information
fredr committed Mar 13, 2024
1 parent 3c15d17 commit 9f3c0de
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions interceptors/retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func UnaryClientInterceptor(optFuncs ...CallOption) grpc.UnaryClientInterceptor
}
var lastErr error
for attempt := uint(0); attempt < callOpts.max; attempt++ {
if attempt > 0 {
callOpts.onRetryCallback(parentCtx, attempt, lastErr)
}
if err := waitRetryBackoff(attempt, parentCtx, callOpts); err != nil {
return err
}
if attempt > 0 {
callOpts.onRetryCallback(parentCtx, attempt, lastErr)
}
callCtx, cancel := perCallContext(parentCtx, callOpts, attempt)
defer cancel() // Clean up potential resources.
lastErr = invoker(callCtx, method, req, reply, cc, grpcOpts...)
Expand Down Expand Up @@ -93,12 +93,12 @@ func StreamClientInterceptor(optFuncs ...CallOption) grpc.StreamClientIntercepto

var lastErr error
for attempt := uint(0); attempt < callOpts.max; attempt++ {
if attempt > 0 {
callOpts.onRetryCallback(parentCtx, attempt, lastErr)
}
if err := waitRetryBackoff(attempt, parentCtx, callOpts); err != nil {
return nil, err
}
if attempt > 0 {
callOpts.onRetryCallback(parentCtx, attempt, lastErr)
}
var newStreamer grpc.ClientStream
newStreamer, lastErr = streamer(parentCtx, desc, cc, method, grpcOpts...)
if lastErr == nil {
Expand Down

0 comments on commit 9f3c0de

Please sign in to comment.