From 9f3c0de3786da1a479abe7390629cad527a8a54a Mon Sep 17 00:00:00 2001 From: Fredrik Enestad Date: Wed, 13 Mar 2024 10:22:20 +0100 Subject: [PATCH] after backoff wait --- interceptors/retry/retry.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interceptors/retry/retry.go b/interceptors/retry/retry.go index 278228f5..f89d687c 100644 --- a/interceptors/retry/retry.go +++ b/interceptors/retry/retry.go @@ -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...) @@ -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 {