backoff

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Const

type Const time.Duration

Const represents a fixed duration backoff strategy.

func (Const) Timeout

func (b Const) Timeout(int) time.Duration

type Exp

type Exp struct {
	Base   time.Duration
	Factor float64
}

Exp provides exponential backoff `(Base * Factor ^ (retry - 1))`.

func (Exp) Timeout

func (b Exp) Timeout(retry int) time.Duration

type Interface

type Interface interface {

	// Timeout returns sleep duration.
	Timeout(retry int) time.Duration
}

Interface is backoff strategy interface.

type Rand added in v0.11.0

type Rand struct {
	Min, Max time.Duration
}

Rand implements backoff with random timeouts in [Min, Max) interval.

func (Rand) Timeout added in v0.11.0

func (b Rand) Timeout(int) time.Duration

type Retry

type Retry struct {

	// Retries is maximum retries.
	Retries int

	// Backoff is a backoff strategy.
	Backoff Interface

	// Body is an action which will be "retry-managed".
	Body func(context.Context) error
}

Retry describes a retry strategy.

func (Retry) Do

func (r Retry) Do(ctx context.Context) (err error)

Do retries the action until it succeeds or maximum retries is reached.

type Temporary

type Temporary interface {
	IsTemporary(err error) bool
}

Temporary checks if the provided error is temporary.

Jump to

Keyboard shortcuts

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