backoff

package
v1.6.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateDuration

func CalculateDuration(min, max time.Duration, factor float64, jitter bool, failures int) time.Duration

CalculateDuration calculates the backoff duration based on minimum base interval, exponential factor, jitter and number of failures.

Types

type Exponential

type Exponential struct {
	// Min is the minimal backoff time, if unspecified, 1 second will be
	// used
	Min time.Duration

	// Max is the maximum backoff time, if unspecified, no maximum time is
	// applied
	Max time.Duration

	// Factor is the factor the backoff time grows exponentially, if
	// unspecified, a factor of 2.0 will be used
	Factor float64

	// Jitter, when enabled, adds random jitter to the interval
	Jitter bool

	// NodeManager enables the use of cluster size dependent backoff
	// intervals, i.e. the larger the cluster, the longer the backoff
	// interval
	NodeManager NodeManager

	// Name is a free form string describing the operation subject to the
	// backoff, if unspecified, a UUID is generated. This string is used
	// for logging purposes.
	Name string
	// contains filtered or unexported fields
}

Exponential implements an exponential backoff

func (*Exponential) Duration

func (b *Exponential) Duration(attempt int) time.Duration

Duration returns the wait duration for the nth attempt

func (*Exponential) Wait

func (b *Exponential) Wait(ctx context.Context) error

Wait waits for the required time using an exponential backoff

type NodeManager

type NodeManager interface {
	ClusterSizeDependantInterval(baseInterval time.Duration) time.Duration
}

NodeManager is the interface required to implement cluster size dependent intervals

Jump to

Keyboard shortcuts

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