Retry uses exponential backoff with timeout.
(ctx context.Context, fn func() error)
| 16 | |
| 17 | // Retry uses exponential backoff with timeout. |
| 18 | func Retry(ctx context.Context, fn func() error) error { |
| 19 | b := backoff.NewExponentialBackOff() |
| 20 | b.InitialInterval = initialInterval |
| 21 | |
| 22 | _, err := backoff.Retry(ctx, func() (struct{}, error) { |
| 23 | return struct{}{}, fn() |
| 24 | }, backoff.WithBackOff(b), backoff.WithMaxElapsedTime(timeout), backoff.WithMaxTries(3)) |
| 25 | return err |
| 26 | } |
no outgoing calls
no test coverage detected