Documentation
¶
Overview ¶
Package retry provides general retry logic and designated error structure that contains multiple errors.
Index ¶
- func Retry(trial uint, function func() error) error
- func WithBackOff(trial uint, function func() error, meanInterval time.Duration, ...) error
- func WithInterval(trial uint, function func() error, interval time.Duration) error
- func WithPolicy(policy *Policy, function func() error) error
- type Errors
- type Policy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Retry ¶
Retry retries given function as many times as the maximum trial count. It quits retrial when the function returns no error, which is nil.
func WithBackOff ¶
func WithBackOff(trial uint, function func() error, meanInterval time.Duration, randFactor float64) error
WithBackOff retries given function at interval, but the interval differs every time. The base interval and randomization factor are specified as 3rd and 4th arguments.
func WithInterval ¶
WithInterval retries given function at interval.
func WithPolicy ¶ added in v1.4.0
WithPolicy receives retrial policy and an executable function. Passed function is recursively executed as long as it returns an error or the retrial count exceeds given configuration value. Unlike other retrial functions, this function is among the most flexible since a user has maximum freedom on configuration.
Types ¶
type Errors ¶
type Errors []error
Errors is an alias for slice of error that contains ordered error that occurred during retrials. This implements Error method to satisfy error interface, which returns concatenated message of all belonging errors.
Since this is an alias to []error, each belonging error is accessible in a way such as:
for i, err := range *errs { ... }