From 26c1de3cde78afa285128ca703237c10765751cf Mon Sep 17 00:00:00 2001 From: Danlock Date: Sat, 14 Oct 2023 11:26:02 -0400 Subject: [PATCH] internal.Retry now slightly faster --- internal/util.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/util.go b/internal/util.go index 7f05de1..ff1d3e8 100644 --- a/internal/util.go +++ b/internal/util.go @@ -63,17 +63,17 @@ func Retry(ctx context.Context, delayForAttempt func(int) time.Duration, do func var delay time.Duration var attempt = 0 for { - select { - case <-ctx.Done(): - return - case <-time.After(delay): - } - delay = delayForAttempt(attempt) attempt++ lifetime, ok := do(delay) if ok && lifetime >= healthyLifetime { delay, attempt = 0, 0 } + + select { + case <-ctx.Done(): + return + case <-time.After(delay): + } } }