beats: github.com/elastic/beats/libbeat/common/backoff Index | Files

package backoff

import "github.com/elastic/beats/libbeat/common/backoff"

Index

Package Files

backoff.go equal_jitter.go exponential.go

func WaitOnError Uses

func WaitOnError(b Backoff, err error) bool

WaitOnError is a convenience method, if an error is received it will block, if not errors is received, the backoff will be resetted.

type Backoff Uses

type Backoff interface {
    // Wait blocks for a duration of time governed by the backoff strategy.
    Wait() bool

    // Reset resets the backoff duration to an initial value governed by the backoff strategy.
    Reset()
}

Backoff defines the interface for backoff strategies.

func NewEqualJitterBackoff Uses

func NewEqualJitterBackoff(done <-chan struct{}, init, max time.Duration) Backoff

NewEqualJitterBackoff returns a new EqualJitter object.

func NewExpBackoff Uses

func NewExpBackoff(done <-chan struct{}, init, max time.Duration) Backoff

NewExpBackoff returns a new exponential backoff.

type EqualJitterBackoff Uses

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

EqualJitterBackoff implements an equal jitter strategy, meaning the wait time will consist of two parts, the first will be exponential and the other half will be random and will provide the jitter necessary to distribute the wait on remote endpoint.

func (*EqualJitterBackoff) Reset Uses

func (b *EqualJitterBackoff) Reset()

Reset resets the duration of the backoff.

func (*EqualJitterBackoff) Wait Uses

func (b *EqualJitterBackoff) Wait() bool

Wait block until either the timer is completed or channel is done.

type ExpBackoff Uses

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

ExpBackoff exponential backoff, will wait an initial time and exponentialy increases the wait time up to a predefined maximun. Resetting Backoff will reset the next sleep timer to the initial backoff duration.

func (*ExpBackoff) Reset Uses

func (b *ExpBackoff) Reset()

Reset resets the duration of the backoff.

func (*ExpBackoff) Wait Uses

func (b *ExpBackoff) Wait() bool

Wait block until either the timer is completed or channel is done.

Package backoff imports 2 packages (graph) and is imported by 34 packages. Updated 2020-06-04. Refresh now. Tools for package owners.