backoff

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultBackoff

type DefaultBackoff struct {
	// contains filtered or unexported fields
}

DefaultBackoff computes the delay before retrying an action. It uses an exponential backoff with jitter. The jitter represents up to 20 percents of the delay.

func (*DefaultBackoff) IsMaxBackoffReached

func (b *DefaultBackoff) IsMaxBackoffReached() bool

IsMaxBackoffReached evaluates if the max number of retries is reached

func (*DefaultBackoff) Next

func (b *DefaultBackoff) Next() time.Duration

Next returns the delay to wait before next retry

func (*DefaultBackoff) Reset

func (b *DefaultBackoff) Reset()

type Policy

type Policy interface {
	// Next returns the delay to wait before next retry
	Next() time.Duration

	// IsMaxBackoffReached evaluates if the max number of retries is reached
	IsMaxBackoffReached() bool

	// Reset the backoff to the initial state
	Reset()
}

Policy parameterize the following options in the reconnection logic to allow users to customize the reconnection logic (minBackoff, maxBackoff and jitterPercentage)

func NewDefaultBackoff

func NewDefaultBackoff() Policy

func NewDefaultBackoffWithInitialBackOff

func NewDefaultBackoffWithInitialBackOff(backoff time.Duration) Policy

Jump to

Keyboard shortcuts

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