Documentation
Overview ¶
Package retry contains utilities for implementing retry logic.
Index ¶
Constants ¶
const MaxBackoffMax = time.Duration(maxInt64Convertible)
MaxBackoffMax is the maximum value that can be passed as max to Backoff.
Variables ¶
Functions ¶
Types ¶
type Policy ¶
type Policy interface { // Retry tells whether the a new retry should be attempted, // and after how long. Retry(retry int) (bool, time.Duration) }
A Policy is an interface that abstracts retry policies. Typically users will not call methods directly on a Policy but rather use the package function retry.Wait.
func Backoff ¶
Backoff returns a Policy that initially waits for the amount of time specified by parameter initial; on each try this value is multiplied by the provided factor, up to the max duration.
func Jitter ¶
Jitter returns a policy that jitters 'frac' fraction of the wait times returned by the provided policy. For example, setting frac to 1.0 and 0.5 will implement "full jitter" and "equal jitter" approaches respectively. These approaches are describer here:
func MaxTries ¶
MaxTries returns a policy that enforces a maximum number of attempts. The provided policy is invoked when the current number of tries is within the permissible limit. If policy is nil, the returned policy will permit an immediate retry when the number of tries is within the allowable limits.