Documentation ¶
Overview ¶
Package retry implements exponential retry policy.
Index ¶
- func Always(err error) bool
- func Periodically(ctx context.Context, interval time.Duration, count int, desc string, ...) (interface{}, error)
- func PeriodicallyNoValue(ctx context.Context, interval time.Duration, count int, desc string, ...) error
- func WithExponentialBackoff(ctx context.Context, desc string, attempt AttemptFunc, ...) (interface{}, error)
- func WithExponentialBackoffNoValue(ctx context.Context, desc string, attempt func() error, ...) error
- type AttemptFunc
- type IsRetriableFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Periodically ¶ added in v0.5.2
func Periodically(ctx context.Context, interval time.Duration, count int, desc string, attempt AttemptFunc, isRetriableError IsRetriableFunc) (interface{}, error)
Periodically runs the provided attempt until it succeeds, waiting given fixed amount between attempts.
func PeriodicallyNoValue ¶ added in v0.5.2
func PeriodicallyNoValue(ctx context.Context, interval time.Duration, count int, desc string, attempt func() error, isRetriableError IsRetriableFunc) error
PeriodicallyNoValue runs the provided attempt until it succeeds, waiting given fixed amount between attempts.
func WithExponentialBackoff ¶
func WithExponentialBackoff(ctx context.Context, desc string, attempt AttemptFunc, isRetriableError IsRetriableFunc) (interface{}, error)
WithExponentialBackoff runs the provided attempt until it succeeds, retrying on all errors that are deemed retriable by the provided function. The delay between retries grows exponentially up to a certain limit.
func WithExponentialBackoffNoValue ¶
func WithExponentialBackoffNoValue(ctx context.Context, desc string, attempt func() error, isRetriableError IsRetriableFunc) error
WithExponentialBackoffNoValue is a shorthand for WithExponentialBackoff except the attempt function does not return any value.
Types ¶
type AttemptFunc ¶
type AttemptFunc func() (interface{}, error)
AttemptFunc performs an attempt and returns a value (optional, may be nil) and an error.
type IsRetriableFunc ¶
IsRetriableFunc is a function that determines whether an error is retriable.