backoff

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: ISC Imports: 4 Imported by: 0

Documentation

Overview

Package backoff provides an exponential-backoff implementation partially taken from jpillora/backoff.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

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

Backoff is a time.Duration counter, starting at Min. After every call to the Duration method the current timing is multiplied by Factor, but it never exceeds Max.

func NewBackoff

func NewBackoff(min, max time.Duration) Backoff

NewBackoff creates a new backoff time.Duration counter.

func (*Backoff) Next

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

Next returns the next backoff duration.

type Timer

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

Timer is a backoff timer.

func NewTimer

func NewTimer(min, max time.Duration) Timer

NewTimer returns a new uninitialized timer.

func (*Timer) Next

func (t *Timer) Next() <-chan time.Time

Next initializes the timer if needed and returns a timer channel that fires when the backoff timeout is reached.

func (*Timer) Stop

func (t *Timer) Stop()

Stop stops the internal timer and frees its resources. It does nothing if the timer is uninitialized.

Jump to

Keyboard shortcuts

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