Backoff is used to wait according to exponential backoff. Returns false if the maximum number of retries have been used or if the underlying context has been cancelled.
(ctx context.Context)
| 87 | // Backoff is used to wait according to exponential backoff. Returns false if the |
| 88 | // maximum number of retries have been used or if the underlying context has been cancelled. |
| 89 | func (b *BackoffHandler) Backoff(ctx context.Context) bool { |
| 90 | c := b.BackoffTimer() |
| 91 | if c == nil { |
| 92 | return false |
| 93 | } |
| 94 | select { |
| 95 | case <-c: |
| 96 | return true |
| 97 | case <-ctx.Done(): |
| 98 | return false |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // Sets a grace period within which the backoff timer is maintained. After the grace |
| 103 | // period expires, the number of retries & backoff duration is reset. |