Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultMaxDelay 默认最大等待时间 DefaultMaxDelay = 20 * time.Second // DefaultBaseDelay 默认基础等待时间 DefaultBaseDelay = 200 * time.Millisecond // DefaultRandomMinDelay 默认随机最小等待时间 DefaultRandomMinDelay = 0 // DefaultRandomMaxDelay 默认随机最大等待时间 DefaultRandomMaxDelay = 200 * time.Millisecond )
Variables ¶
View Source
var DefaultExponentialRetryRule = NewExponentialRetryRule(DefaultBaseDelay, DefaultMaxDelay)
View Source
var DefaultFixedRetryRule = NewFixedRetryRule(DefaultBaseDelay)
View Source
var DefaultLinearRetryRule = NewLinearRetryRule(DefaultBaseDelay, DefaultMaxDelay)
View Source
var DefaultNoDelayRetryRule = NewNoDelayRetryRule()
View Source
var DefaultRandomRetryRule = NewRandomRetryRule(DefaultRandomMinDelay, DefaultRandomMaxDelay)
Functions ¶
func IsCodeExpiredCreds ¶
func IsCodeRetryable ¶
func ShouldRetry ¶
ShouldRetry 判断是否需要重试 重试条件: 1.状态码为5xx 2.状态码在retryErrorCodes中 3.错误码在retryableCodes中
Types ¶
type ExponentialRetryRule ¶
type ExponentialRetryRule struct {
// contains filtered or unexported fields
}
ExponentialRetryRule 指数级增长等待时间重试规则
func NewExponentialRetryRule ¶
func NewExponentialRetryRule(baseDelay time.Duration, maxDelay time.Duration) ExponentialRetryRule
type FixedRetryRule ¶
type FixedRetryRule struct {
// contains filtered or unexported fields
}
FixedRetryRule 固定等待时间重试规则
func NewFixedRetryRule ¶
func NewFixedRetryRule(baseDelay time.Duration) FixedRetryRule
type LinearRetryRule ¶
type LinearRetryRule struct {
// contains filtered or unexported fields
}
LinearRetryRule 线性增长等待时间重试规则
func NewLinearRetryRule ¶
func NewLinearRetryRule(baseDelay time.Duration, maxDelay time.Duration) LinearRetryRule
type NoDelayRetryRule ¶
type NoDelayRetryRule struct{}
NoDelayRetryRule 不等待重试规则(立即重试)
func NewNoDelayRetryRule ¶
func NewNoDelayRetryRule() NoDelayRetryRule
type RandomRetryRule ¶
type RandomRetryRule struct {
// contains filtered or unexported fields
}
RandomRetryRule 随机等待时间重试规则
func NewRandomRetryRule ¶
func NewRandomRetryRule(minDelay time.Duration, maxDelay time.Duration) RandomRetryRule
Click to show internal directories.
Click to hide internal directories.