Wait sleeps for the backoff time then increases the retry count and backoff time Returns immediately if Context is terminated
()
| 82 | // Wait sleeps for the backoff time then increases the retry count and backoff time |
| 83 | // Returns immediately if Context is terminated |
| 84 | func (b *Backoff) Wait() { |
| 85 | // Increase the number of retries and get the next delay |
| 86 | sleepTime := b.NextDelay() |
| 87 | |
| 88 | if b.Ongoing() { |
| 89 | timer := time.NewTimer(sleepTime) |
| 90 | defer timer.Stop() |
| 91 | |
| 92 | select { |
| 93 | case <-b.ctx.Done(): |
| 94 | case <-timer.C: |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | func (b *Backoff) NextDelay() time.Duration { |
| 100 | b.numRetries++ |