backoff

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFactor factor
	DefaultFactor = math.E
	// DefaultJitter jitter
	DefaultJitter = true
	// DefaultMaxInterval max interval
	DefaultMaxInterval = 3 * time.Minute
	// DefaultMinInterval min interval
	DefaultMinInterval = 100 * time.Millisecond
	// MaxInt64 the max int64 to avoid overflow
	MaxInt64 = float64(math.MaxInt64 - 1024)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

type Backoff struct {
	Factor float64
	Jitter bool
	Max    time.Duration
	Min    time.Duration
	// contains filtered or unexported fields
}

Backoff struct

func Default

func Default() *Backoff

Default return backoff instance with default value

func New

func New(factor float64, jitter bool, max, min time.Duration) *Backoff

New create backoff instance

func WithoutJitter

func WithoutJitter() *Backoff

WithoutJitter return backoff instance with default value except jitter

func (*Backoff) Attempts

func (b *Backoff) Attempts() uint64

Attempts return the attempt times

func (*Backoff) Next

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

Next return next interval time to backoff

func (*Backoff) Reset

func (b *Backoff) Reset()

Reset use for reset backoff attempt times

Jump to

Keyboard shortcuts

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