Versions in this module Expand all Collapse all v1 v1.0.0 Apr 2, 2022 Changes in this version + var DefaultMaxRetryTimes = 3 + var DefaultRetryChecker = func(err error) bool + var DefaultTimeout = time.Minute + var ErrorAbort = errors.New("stop retry") + var ErrorContextDeadlineExceed = errors.New("context deadline exceeded") + var ErrorEmptyRetryFunc = errors.New("empty retry function") + var ErrorTimeout = errors.New("retry timeout") + func Do(ctx context.Context, fn RetryFunc, opts ...Option) error + type BackoffStrategy int + const StrategyConstant + const StrategyFibonacci + const StrategyLinear + type Config struct + AfterTry HookFunc + BeforeTry HookFunc + MaxRetryTimes int + RecoverPanic bool + RetryChecker func(err error) (needRetry bool) + Strategy Strategy + Timeout time.Duration + type HookFunc func() + type Option func(c *Config) + func WithAfterHook(hook HookFunc) Option + func WithBackOffStrategy(s BackoffStrategy, duration time.Duration) Option + func WithBeforeHook(hook HookFunc) Option + func WithCustomBackOffStrategy(s Strategy) Option + func WithMaxRetryTimes(times int) Option + func WithRecoverPanic() Option + func WithRetryChecker(checker RetryChecker) Option + func WithTimeout(timeout time.Duration) Option + type RetryChecker func(err error) (needRetry bool) + type RetryFunc func() error + type Strategy func(times int) time.Duration + func Constant(d time.Duration) Strategy + func Fibonacci(d time.Duration) Strategy + func Linear(d time.Duration) Strategy