Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backoff ¶
Backoff is a function that provides delay time for retries. A zero or negative value no delay time between retries. The times start from 1, means the first retry
func ExponentialBackoff ¶
ExponentialBackoff provides binary exponential backoff algorithm. Param initialDelay: the intial delay time for first retry.
func FixedBackoff ¶
FixedBackoff provides fixed-delay backoff algorithm. Param delay: the delay time for retries.
type Retryer ¶
type Retryer struct { MaxTimes int // max retry times. A zero or negetive value imply no retries Backoff Backoff // Backoff return delay time for retries. A nil value imply no Backoff Scatter Scatter // Scatter scatter the delay time. A nil value imply no Scatter }
Retryer for retry call a function. This can be reused.
type Scatter ¶
Scatter is a function that distribute the delay to a range of time
func EvenScatter ¶
EvenScatter return a Scatter fucntion that distribute dealy time to range [delay*(1-factor), delay*(1+factor)) The factor shoud in range [0, 1], otherwise will panics.