package
1.3.48
Repository: https://github.com/sandwich-go/boost.git
Documentation: pkg.go.dev

# README

retry

执行函数,若失败,则按配置参数重新执行,直至成功或达到某种指定条件

例子

var retrySum uint
err := Do(
    func(uint) error { return fmt.Errorf("%d", retrySum) },
    WithOnRetry(func(n uint, err error) { retrySum += 1 }),
    WithDelay(time.Nanosecond),
    WithLastErrorOnly(true),
)

fmt.Println(err)

Output:

9

# Functions

BackOffDelay 指数级增长重试的推迟时长.
CombineDelay is a DelayType the combines all of the specified delays into a new DelayTypeFunc.
Do 执行 retryableFunc 函数,若执行失败,则会重新尝试执行.
FixedDelay 固定延时.
InstallOptionsWatchDog the installed func will called when NewOptions called.
IsRecoverable checks if error is an instance of `unrecoverableError`.
NewOptions new Options.
go:generate optionGen --option_return_previous=false.
RandomDelay 随机延时.
Unrecoverable wraps an error in `unrecoverableError` struct.
WithContext context,可以设定超时等.
WithDelay 固定延迟.
WithDelayType 何种error进行重试.
WithLastErrorOnly 是否只返回最后遇到的error.
WithLimit 最大尝试次数.
WithMaxDelay 最大延迟时间.
WithMaxJitter 延迟最大抖动.
WithOnRetry 每次重试会先调用此方法.
WithRetryIf 何种error进行重试.

# Structs

Options should use NewOptions to initialize it.

# Interfaces

OptionsInterface visitor + ApplyOption interface for Options.
OptionsVisitor visitor interface for Options.

# Type aliases

No description provided by the author
Option option func.