Documentation ¶
Overview ¶
Package retry provides generic action retry.
Index ¶
- func ExpectedError(err error) error
- func ExpectedErrorf(format string, a ...interface{}) error
- func IsTimeout(err error) bool
- func UnexpectedError(err error) errordeprecated
- type ConstantTicker
- type ErrorSet
- type ExponentialTicker
- type LinearTicker
- type Option
- type Options
- type RetryableFunc
- type RetryableFuncWithContext
- type Retryer
- type Ticker
- type TimeoutError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpectedError ¶
ExpectedError error represents an error that is expected by the retrying function. This error is ignored.
func ExpectedErrorf ¶
ExpectedErrorf makes an expected error from given format and arguments.
func UnexpectedError
deprecated
Types ¶
type ConstantTicker ¶
type ConstantTicker struct {
// contains filtered or unexported fields
}
ConstantTicker represents a ticker with a constant algorithm.
func NewConstantTicker ¶
func NewConstantTicker(opts *Options) *ConstantTicker
NewConstantTicker is a ticker that sends the time on a channel using a constant algorithm.
func (ConstantTicker) Tick ¶
func (c ConstantTicker) Tick() time.Duration
Tick implements the Ticker interface.
type ErrorSet ¶
type ErrorSet struct {
// contains filtered or unexported fields
}
ErrorSet represents a set of unique errors.
type ExponentialTicker ¶
type ExponentialTicker struct {
// contains filtered or unexported fields
}
ExponentialTicker represents a ticker with a truncated exponential algorithm. Please see https://en.wikipedia.org/wiki/Exponential_backoff for details on the algorithm.
func NewExponentialTicker ¶
func NewExponentialTicker(opts *Options) *ExponentialTicker
NewExponentialTicker is a ticker that sends the time on a channel using a truncated exponential algorithm.
func (*ExponentialTicker) Tick ¶
func (e *ExponentialTicker) Tick() time.Duration
Tick implements the Ticker interface.
type LinearTicker ¶
type LinearTicker struct {
// contains filtered or unexported fields
}
LinearTicker represents a ticker with a linear algorithm.
func NewLinearTicker ¶
func NewLinearTicker(opts *Options) *LinearTicker
NewLinearTicker is a ticker that sends the time on a channel using a linear algorithm.
func (*LinearTicker) Tick ¶
func (l *LinearTicker) Tick() time.Duration
Tick implements the Ticker interface.
type Option ¶
type Option func(*Options)
Option is the functional option func.
func WithAttemptTimeout ¶
WithAttemptTimeout sets timeout for each retry attempt.
func WithErrorLogging ¶
WithErrorLogging logs errors as they are encountered during the retry loop.
func WithJitter ¶
WithJitter is a functional option for setting the jitter flag.
type Options ¶
type Options struct { Units time.Duration Jitter time.Duration AttemptTimeout time.Duration LogErrors bool }
Options is the functional options struct.
func NewDefaultOptions ¶
NewDefaultOptions initializes a Options struct with default values.
type RetryableFunc ¶
type RetryableFunc func() error
RetryableFunc represents a function that can be retried.
type RetryableFuncWithContext ¶
RetryableFuncWithContext represents a function that can be retried.
type Retryer ¶
type Retryer interface { Retry(RetryableFunc) error RetryWithContext(context.Context, RetryableFuncWithContext) error }
Retryer defines the requirements for retrying a function.
func Exponential ¶
Exponential initializes and returns a truncated exponential Retryer.
type TimeoutError ¶
type TimeoutError struct{}
TimeoutError represents a timeout error.
func (TimeoutError) Error ¶
func (TimeoutError) Error() string