backoff

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntervalGenerator

type IntervalGenerator interface {
	Next(attempt int) time.Duration
}

IntervalGenerator used to generate next interval.

type Option

type Option func(policy *exponentialPolicy)

func Jitter

func Jitter(jitter float64) Option

Jitter sets the factor with which backoffs are randomized.

func MaxInterval

func MaxInterval(interval time.Duration) Option

MaxInterval sets the upper bound of backoff delay.

func MinInterval

func MinInterval(minInterval time.Duration) Option

MinInterval sets the amount of time to backoff after the first failure.

func Multiplier

func Multiplier(multiplier float64) Option

Multiplier multiplier is the factor with which to multiply backoffs after a failed retry. Should be greater than 1.

type Policy

type Policy interface {
	New() IntervalGenerator
}

Policy is an interface for the dial policies.

func NewExponentialPolicy

func NewExponentialPolicy(ops ...Option) Policy

NewExponentialPolicy returns a exponential backoff policy

func NewFixedIntervalPolicy

func NewFixedIntervalPolicy(interval time.Duration) Policy

NewFixedIntervalPolicy returns a fixed interval policy

func NewNullPolicy

func NewNullPolicy() Policy

NewNullPolicy does not do any backoff. It always allows the caller to execute dial.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL