Documentation
¶
Overview ¶
Package retrier designed to execute some valuable functionality with retrying policy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllowNextAttemptFunc ¶
AllowNextAttemptFunc is a function to decide if next attempt is allowed.
func LimitAttemptsCount ¶
func LimitAttemptsCount(attempts int) AllowNextAttemptFunc
LimitAttemptsCount returns as AllowNextAttemptFunc with attempts count limit.
type CalcDelayFunc ¶
CalcDelayFunc is a function to calculate a delay before next attempt.
func FixedDelay ¶
func FixedDelay(delay time.Duration) CalcDelayFunc
FixedDelay returns a CalcDelayFunc with a fixed delay value.
func ProgressiveDelay ¶
func ProgressiveDelay(initialDelay time.Duration, multiplier float64) CalcDelayFunc
ProgressiveDelay returns a CalcDelayFunc with a progressively increasing delay.
func WithDelayJitter ¶
func WithDelayJitter(calcDelayFn CalcDelayFunc) CalcDelayFunc
WithDelayJitter adds random jitter to the delay.
func WithMaxDelay ¶
func WithMaxDelay(calcDelayFn CalcDelayFunc, maxDelay time.Duration) CalcDelayFunc
WithMaxDelay adds max delay check to the existing CalcDelayFunc.
type Retrier ¶
type Retrier interface {
// Do execute a Fn and retry it in case of error.
Do(ctx context.Context, fn Fn) error
}
Retrier is a tool to execute Fn with retries.
func New ¶
func New(calcDelayFn CalcDelayFunc, allowNextAttemptFn AllowNextAttemptFunc) Retrier
New returns custom Retrier.