Documentation ¶
Index ¶
- Variables
- func Do(ctx context.Context, fn RetriesFunc, opts ...Option) error
- type BackoffStrategy
- type Config
- type Constant
- type Fibonacci
- type HookFunc
- type Linear
- type Option
- func WithAfterHook(hook HookFunc) Option
- func WithBackOffStrategy(s BackoffStrategy, duration time.Duration) Option
- func WithBeforeHook(hook HookFunc) Option
- func WithCustomStrategy(s Strategy) Option
- func WithMaxRetryTimes(times int) Option
- func WithRecoverPanic() Option
- func WithRetryChecker(checker RetriesChecker) Option
- func WithTimeout(timeout time.Duration) Option
- type RetriesChecker
- type RetriesFunc
- type Strategy
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorAbort = errors.New("stop retry") ErrorTimeout = errors.New("retry timeout") ErrorContextDeadlineExceed = errors.New("context deadline exceeded") ErrorEmptyRetryFunc = errors.New("empty retry function") ErrorTimeFormat = errors.New("time out err") )
View Source
var ( DefaultMaxRetryTimes = 3 DefaultTimeout = time.Minute DefaultInterval = time.Second * 2 DefaultRetryChecker = func(err error) bool { return !errors.Is(err, ErrorAbort) } )
Functions ¶
Types ¶
type BackoffStrategy ¶
type BackoffStrategy int
const ( StrategyConstant BackoffStrategy = iota StrategyLinear StrategyFibonacci )
type Constant ¶
type Constant struct {
// contains filtered or unexported fields
}
func NewConstant ¶
type Fibonacci ¶
type Fibonacci struct {
// contains filtered or unexported fields
}
func NewFibonacci ¶
type Option ¶
type Option func(c *Config)
func WithAfterHook ¶
func WithBackOffStrategy ¶
func WithBackOffStrategy(s BackoffStrategy, duration time.Duration) Option
func WithBeforeHook ¶
func WithCustomStrategy ¶
func WithMaxRetryTimes ¶
func WithRecoverPanic ¶
func WithRecoverPanic() Option
func WithRetryChecker ¶
func WithRetryChecker(checker RetriesChecker) Option
func WithTimeout ¶
type RetriesChecker ¶
type RetriesFunc ¶
type RetriesFunc func() error
Click to show internal directories.
Click to hide internal directories.