backoff

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 10 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 ...Option) (*Backoff, error)

func (*Backoff) Reset

func (b *Backoff) Reset()

func (Backoff) Validate added in v0.0.19

func (b Backoff) Validate() error

func (*Backoff) Wait

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

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 Option added in v0.0.19

type Option = c.Option[Backoff]

func WithMaxRetries

func WithMaxRetries(mr uint32) Option

func WithName

func WithName(name string) Option

func WithStrategy

func WithStrategy(s Strategy) Option

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)

func NewStaticStrategy added in v0.0.16

func NewStaticStrategy(d time.Duration) Strategy

Jump to

Keyboard shortcuts

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