Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backoff ¶
type Backoff struct {
Type BackoffType `json:"type" yaml:"type" ini:"type"` // 递增曲线类型
InitialSleep time.Duration `json:"initial_sleep" yaml:"initial_sleep" ini:"initial_sleep"` // 初始等待时间
MaxSleep time.Duration `json:"max_sleep" yaml:"max_sleep" ini:"max_sleep"` // 最大等待时间
Step time.Duration `json:"step" yaml:"step" ini:"step"` // 线性递增的步长(仅用于 Linear 和 Step 类型)
Base float64 `json:"base" yaml:"base" ini:"base"` // 指数递增的基数(仅用于 Exponential 类型)
StepThreshold int `json:"step_threshold" yaml:"step_threshold" ini:"step_threshold"` // 分段递增的阈值(仅用于 Step 类型)
// contains filtered or unexported fields
}
Backoff 封装了递增睡眠时间的逻辑
func NewBackoff ¶
func NewBackoff(backoffType BackoffType, initialSleep, maxSleep time.Duration, options ...any) *Backoff
NewBackoff 创建一个新的 Backoff 实例
type BackoffType ¶
type BackoffType int
BackoffType 定义递增曲线的类型
const ( Exponential BackoffType = iota // 指数递增 Linear // 线性递增 Logarithmic // 对数递增 Randomized // 随机化递增 Step // 分段递增 )
Click to show internal directories.
Click to hide internal directories.