backoff

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyStat = Stat{}

Functions

This section is empty.

Types

type Backoff

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

func New

func New(opts ...BackoffOption) (*Backoff, error)

func (*Backoff) Reset

func (b *Backoff) Reset()

func (*Backoff) Wait

func (b *Backoff) Wait(ctx context.Context) (Stat, error)

type BackoffOption

type BackoffOption = c.Option[Backoff]

func WithMaxRetries

func WithMaxRetries(mr uint32) BackoffOption

func WithName

func WithName(name string) BackoffOption

func WithStrategy

func WithStrategy(s Strategy) BackoffOption

type ExponentialOption

type ExponentialOption = c.Option[exponential]

func WithJitter

func WithJitter(j float64) ExponentialOption

func WithMaxDelay

func WithMaxDelay(d time.Duration) ExponentialOption

func WithMinDelay

func WithMinDelay(d time.Duration) ExponentialOption

func WithMultiplier

func WithMultiplier(m float64) ExponentialOption

type RetryLimitError

type RetryLimitError struct {
	BackoffName string
	MaxRetries  uint32
}

func (RetryLimitError) Error

func (e RetryLimitError) Error() string

type Stat

type Stat struct {
	Duration   time.Duration
	RetryIndex uint32
	MaxRetries uint32
}

func (Stat) String

func (s Stat) String() string

type Strategy

type Strategy interface {
	Duration(retries uint32) time.Duration
}

func NewExponentialStrategy

func NewExponentialStrategy(opts ...ExponentialOption) (Strategy, error)

Jump to

Keyboard shortcuts

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