(ctx context.Context, duration time.Duration)
| 416 | } |
| 417 | |
| 418 | func sleep(ctx context.Context, duration time.Duration) bool { |
| 419 | if duration == 0 { |
| 420 | select { |
| 421 | default: |
| 422 | return true |
| 423 | case <-ctx.Done(): |
| 424 | return false |
| 425 | } |
| 426 | } |
| 427 | timer := time.NewTimer(duration) |
| 428 | defer timer.Stop() |
| 429 | select { |
| 430 | case <-timer.C: |
| 431 | return true |
| 432 | case <-ctx.Done(): |
| 433 | return false |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | func backoff(attempt int, min time.Duration, max time.Duration) time.Duration { |
| 438 | d := time.Duration(attempt*attempt) * min |
no test coverage detected