Documentation ¶
Index ¶
- Variables
- func BackOffDelay(n uint, config *Config) time.Duration
- func Do(retryableFunc RetryableFunc, opts ...Option) error
- func FixedDelay(_ uint, config *Config) time.Duration
- func IsRecoverable(err error) bool
- func RandomDelay(_ uint, config *Config) time.Duration
- func Unrecoverable(err error) error
- type Config
- type DelayTypeFunc
- type Error
- type OnRetryFunc
- type Option
- func Attempts(attempts uint) Option
- func Delay(delay time.Duration) Option
- func DelayType(delayType DelayTypeFunc) Option
- func LastErrorOnly(lastErrorOnly bool) Option
- func MaxDelay(maxDelay time.Duration) Option
- func MaxJitter(maxJitter time.Duration) Option
- func OnRetry(onRetry OnRetryFunc) Option
- type RetryableFunc
Constants ¶
This section is empty.
Variables ¶
var ( DefaultAttempts = uint(10) DefaultDelay = 100 * time.Millisecond DefaultMaxJitter = 100 * time.Millisecond DefaultOnRetry = func(n uint, err error) {} DefaultRetryIf = IsRecoverable DefaultDelayType = CombineDelay(FixedDelay, RandomDelay) DefaultLastErrorOnly = false )
Functions ¶
func BackOffDelay ¶
BackOffDelay is a DelayType which increases delay between consecutive retries
func Do ¶
func Do(retryableFunc RetryableFunc, opts ...Option) error
func FixedDelay ¶
FixedDelay is a DelayType which keeps delay the same through all iterations
func IsRecoverable ¶
IsRecoverable checks if error is an instance of `unrecoverableError`
func RandomDelay ¶
RandomDelay is a DelayType which picks a random delay up to config.maxJitter
func Unrecoverable ¶
Unrecoverable wraps an error in `unrecoverableError` struct
Types ¶
type DelayTypeFunc ¶
func CombineDelay ¶
func CombineDelay(delays ...DelayTypeFunc) DelayTypeFunc
CombineDelay is a DelayType the combines all of the specified delays into a new DelayTypeFunc
type Error ¶
type Error []error
Error type represents list of errors in retry
func (Error) Error ¶
Error method return string representation of Error It is an implementation of error interface
func (Error) WrappedErrors ¶
WrappedErrors returns the list of errors that this Error is wrapping. It is an implementation of the `errwrap.Wrapper` interface in package [errwrap](https://github.com/hashicorp/errwrap) so that `retry.Error` can be used with that library.
type OnRetryFunc ¶
Function signature of OnRetry function n = count of attempts
type Option ¶
type Option func(*Config)
Option represents an option for retry.
func DelayType ¶
func DelayType(delayType DelayTypeFunc) Option
DelayType set type of the delay between retries default is BackOff
func LastErrorOnly ¶
return the direct last error that came from the retried function default is false (return wrapped errors with everything)
func OnRetry ¶
func OnRetry(onRetry OnRetryFunc) Option
type RetryableFunc ¶
type RetryableFunc func() error