Skip to content

Commit

Permalink
internal.Retry now slightly faster
Browse files Browse the repository at this point in the history
  • Loading branch information
Danlock committed Oct 14, 2023
1 parent 9171254 commit 26c1de3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
}
}
}

0 comments on commit 26c1de3

Please sign in to comment.