Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Strategy ¶
type Strategy interface {
// Backoff 方法设置重试间隔策略函数。
Backoff(backoffFunc backoff.BackoffFunc) Strategy
// RetryOn 方法判断是否重试。
RetryOn(retryOnFunc func(err error) bool) Strategy
// Exec 方法执行一个命令,并允许传递上下文和当前尝试次数。
Exec(ctx context.Context, cmd func(ctx context.Context, attempt uint) error) error
}
Strategy 接口定义了一个 Backoff 方法,用于设置重试间隔策略。
func MaxAttempts ¶
MaxAttempts 函数创建一个具有指定最大重试次数的 defaultStrategy 实例。
Click to show internal directories.
Click to hide internal directories.