Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBackoff ¶
func WithBackoff( ctx context.Context, retryableFunc RetryableFunc, retryable IsRetryable, b backoff.Backoff, settings Settings, ) (err error)
WithBackoff retries the passed function if it fails and the error allows it to retry. The specified backoff policy is used to determine how long to sleep between attempts.
Types ¶
type IsRetryable ¶
IsRetryable checks whether a new attempt can be started based on the error passed.
type RetryableFunc ¶
RetryableFunc is a retryable function.
type Settings ¶
type Settings struct {
// Timeout lets WithBackoff give up once elapsed (if >0).
Timeout time.Duration
// OnError is called if an error occurs.
OnError func(elapsed time.Duration, attempt uint64, err, lastErr error)
// OnSuccess is called once the operation succeeds.
OnSuccess func(elapsed time.Duration, attempt uint64, lastErr error)
}
Settings aggregates optional settings for WithBackoff.