Documentation
¶
Index ¶
- type ErrorCallback
- type Retry
- type RetryCancelError
- type RetryError
- type RetryErrorScope
- type Retryable
- type Retryer
- type RetryerOptsFunc
- func WithErrorCallback(c ErrorCallback) RetryerOptsFunc
- func WithExponentialBackoff(factor uint) RetryerOptsFunc
- func WithLoggingOnAttemptError(severity logrus.Level) RetryerOptsFunc
- func WithMaxAttempts(maxAttempts int) RetryerOptsFunc
- func WithMaxDuration(duration time.Duration) RetryerOptsFunc
- func WithWaitDuration(duration time.Duration) RetryerOptsFunc
- func WithoutMaxAttempts() RetryerOptsFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorCallback ¶
type RetryCancelError ¶
type RetryCancelError struct {
// contains filtered or unexported fields
}
RetryCancelError is a error wrapping type that the user of a Retry should use to cancel retry operations before the end of maxAttempts/maxDuration conditions
func NewRetryCancelError ¶
func NewRetryCancelError(err error) RetryCancelError
func (RetryCancelError) Error ¶
func (err RetryCancelError) Error() string
func (RetryCancelError) Unwrap ¶ added in v1.3.0
func (err RetryCancelError) Unwrap() error
type RetryError ¶
type RetryError struct {
Scope RetryErrorScope
Err error
LastErr error
}
func (RetryError) Error ¶
func (err RetryError) Error() string
func (RetryError) Unwrap ¶ added in v1.3.0
func (err RetryError) Unwrap() error
type RetryErrorScope ¶
type RetryErrorScope string
const ( MaxDurationScope RetryErrorScope = "max-duration" ContextScope RetryErrorScope = "context" )
type Retryer ¶
type Retryer struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...RetryerOptsFunc) Retryer
type RetryerOptsFunc ¶
type RetryerOptsFunc func(r *Retryer)
func WithErrorCallback ¶
func WithErrorCallback(c ErrorCallback) RetryerOptsFunc
func WithExponentialBackoff ¶ added in v1.4.0
func WithExponentialBackoff(factor uint) RetryerOptsFunc
WithExponentialBackoff enables the exponential backoff wait duration. When enabled, the delay between each attempt is the wait duration multiplied by the given factor. For example, with a wait duration of 100ms and a factor of 2: Attempt 1: Wait 100 milliseconds (100 * 2^0) Attempt 2: Wait 200 milliseconds (100 * 2^1) Attempt 3: Wait 400 milliseconds (100 * 2^2) Attempt 4: Wait 800 milliseconds (100 * 2^3)
func WithLoggingOnAttemptError ¶ added in v1.2.2
func WithLoggingOnAttemptError(severity logrus.Level) RetryerOptsFunc
WithLoggingOnAttemptError allows emitting a log message on each attempt which failed. The capacity to specify the severity of the log message is useful to avoid flooding the logs with too many messages in case of a retry loop. Most of the time it will be Debug or Info according to the type of operation. Error should be chosen carefully if logger was configured to send Errors to a tool like Rollbar/Sentry/...
func WithMaxAttempts ¶
func WithMaxAttempts(maxAttempts int) RetryerOptsFunc
func WithMaxDuration ¶
func WithMaxDuration(duration time.Duration) RetryerOptsFunc
func WithWaitDuration ¶
func WithWaitDuration(duration time.Duration) RetryerOptsFunc
func WithoutMaxAttempts ¶
func WithoutMaxAttempts() RetryerOptsFunc