Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultExponential = &ExponentialStrategy{
opts: defaultExponentialOpts,
}
DefaultExponential is an exponential backoff.Strategy with full jitter. The first attempt has a range of 0 to 10ms and each successive attempt doubles the range of the possible delay.
Exponential strategies are not thread safe. The Backoff() method returns a referentially independent backoff generator and random number generator.
Functions ¶
This section is empty.
Types ¶
type ExponentialOption ¶
type ExponentialOption func(*exponentialOptions)
ExponentialOption defines options that can be applied to an exponential backoff strategy
func FirstBackoff ¶
func FirstBackoff(t time.Duration) ExponentialOption
FirstBackoff sets the initial range of durations that the first backoff duration will provide. The range of durations will double for each successive attempt.
func MaxBackoff ¶
func MaxBackoff(t time.Duration) ExponentialOption
MaxBackoff sets absolute max time that will ever be returned for a backoff.
type ExponentialStrategy ¶
type ExponentialStrategy struct {
// contains filtered or unexported fields
}
ExponentialStrategy can create instances of the exponential backoff strategy with full jitter. Each instance has referentially independent random number generators.
func NewExponential ¶
func NewExponential(opts ...ExponentialOption) (*ExponentialStrategy, error)
NewExponential returns a new exponential backoff strategy, which in turn returns backoff functions.
Exponential is an exponential backoff strategy with jitter. Under the AWS backoff strategies this is a "Full Jitter" backoff implementation https://www.awsarchitectureblog.com/2015/03/backoff.html with the addition of a Min and Max Value. The range of durations will be contained in a closed [Min, Max] interval.
Backoff functions are lockless and referentially independent, but not thread-safe.
func (*ExponentialStrategy) Backoff ¶
func (e *ExponentialStrategy) Backoff() backoff.Backoff
Backoff returns an instance of the exponential backoff strategy with its own random number generator.
func (*ExponentialStrategy) IsEqual ¶
func (e *ExponentialStrategy) IsEqual(o *ExponentialStrategy) bool
IsEqual returns whether this strategy is equivalent to another strategy.