Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultBackOffConfig = BackOffConfig{ MaxDelay: 120 * time.Second, BaseDelay: 1.0 * time.Second, Factor: 1.6, Jitter: 0.2, }
Functions ¶
func WithRetry ¶
func WithRetry(retries int, backOff BackOffConfig, taskFn func() error) error
WithRetry: support backOff
func WithSimpleRetry ¶
WithRetry: support backOff, 自动重试, 支持回退策略
Types ¶
type BackOff ¶
type BackOff interface { // BackOff returns the amount of time to wait before the next retry given // the number of consecutive failures. BackOff(retries int) time.Duration }
BackOff defines the methodology for backing off after a call failure.
type BackOffConfig ¶
type BackOffConfig struct { // MaxDelay is the upper bound of BackOff delay. MaxDelay time.Duration // baseDelay is the amount of time to wait before retrying after the first // failure. BaseDelay time.Duration // factor is applied to the BackOff after each retry. Factor float64 // jitter provides a range to randomize BackOff delays. Jitter float64 }
BackOffConfig defines the parameters for the default BackOff strategy.
Click to show internal directories.
Click to hide internal directories.