Documentation ¶
Overview ¶
Package retry provides a simple yet powerful retry mechanism for Go.
Index ¶
- Variables
- func WithBackoff(ctx context.Context, doFunc RetryableFunc, ...) error
- type RetryableFunc
- type WithBackoffConfigurator
- func WithFactor(factor float64) WithBackoffConfigurator
- func WithJitter(jitter bool) WithBackoffConfigurator
- func WithMax(max time.Duration) WithBackoffConfigurator
- func WithMaxAttemptTime(maxAttemptTime time.Duration) WithBackoffConfigurator
- func WithMaxAttempts(maxAttempts int) WithBackoffConfigurator
- func WithMaxTotalTime(maxTotalTime time.Duration) WithBackoffConfigurator
- func WithMin(min time.Duration) WithBackoffConfigurator
Constants ¶
This section is empty.
Variables ¶
var ErrMaxAttempts = errors.New("max attempts reached")
ErrMaxAttempts is returned when the maximum number of retry attempts is reached.
var ErrMaxTime = errors.New("max time reached")
ErrMaxTime is returned when the maximum time for all retry attempts is reached.
var ErrUnknown = errors.New("unknown error")
ErrUnknown is returned when an unknown error occurs.
Functions ¶
func WithBackoff ¶
func WithBackoff(ctx context.Context, doFunc RetryableFunc, configurators ...WithBackoffConfigurator) error
WithBackoff retries the given function with exponential backoff.
Types ¶
type RetryableFunc ¶
RetryableFunc is a function that can be retried.
type WithBackoffConfigurator ¶
type WithBackoffConfigurator func(*retryWithBackoffConfig)
WithBackoffConfigurator configures a retryWithBackoffConfig.
func WithFactor ¶
func WithFactor(factor float64) WithBackoffConfigurator
WithFactor sets the backoff factor.
func WithJitter ¶
func WithJitter(jitter bool) WithBackoffConfigurator
WithJitter enables or disables jitter.
func WithMax ¶
func WithMax(max time.Duration) WithBackoffConfigurator
WithMax sets the maximum backoff duration.
func WithMaxAttemptTime ¶
func WithMaxAttemptTime(maxAttemptTime time.Duration) WithBackoffConfigurator
WithMaxAttemptTime sets the maximum time of all retry attempts.
func WithMaxAttempts ¶
func WithMaxAttempts(maxAttempts int) WithBackoffConfigurator
WithMaxAttempts sets the maximum number of retry attempts.
func WithMaxTotalTime ¶ added in v0.0.72
func WithMaxTotalTime(maxTotalTime time.Duration) WithBackoffConfigurator
WithMaxTotalTime sets the maximum time of all retry attempts combined.
func WithMin ¶
func WithMin(min time.Duration) WithBackoffConfigurator
WithMin sets the minimum backoff duration.