backoff

package
v0.0.0-...-61eb987 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPermanent = errors.New("permanent error, do not retry")

Functions

This section is empty.

Types

type Backoff

type Backoff interface {
	RetryNotify(Operation, Notify) error
	Retry(Operation) error
}

type Config

type Config struct {
	Exponential *ExponentialConfig
	Constant    *ConstantConfig
}

type ConstantBackoff

type ConstantBackoff struct {
	backoff.BackOff
}

func NewConstantBackoff

func NewConstantBackoff(ctx context.Context, cfg *ConstantConfig) *ConstantBackoff

func (*ConstantBackoff) Retry

func (cbo *ConstantBackoff) Retry(op Operation) error

func (*ConstantBackoff) RetryNotify

func (cbo *ConstantBackoff) RetryNotify(op Operation, notify Notify) error

type ConstantConfig

type ConstantConfig struct {
	Interval   time.Duration
	MaxRetries uint
}

type ExponentialBackoff

type ExponentialBackoff struct {
	backoff.BackOff
}

ExponentialBackoff is a wrapper around the cenkalti exponential backoff

func NewExponentialBackoff

func NewExponentialBackoff(ctx context.Context, cfg *ExponentialConfig) *ExponentialBackoff

func (*ExponentialBackoff) Retry

func (ebo *ExponentialBackoff) Retry(op Operation) error

func (*ExponentialBackoff) RetryNotify

func (ebo *ExponentialBackoff) RetryNotify(op Operation, notify Notify) error

type ExponentialConfig

type ExponentialConfig struct {
	InitialInterval time.Duration
	MaxInterval     time.Duration
	MaxRetries      uint
}

type Notify

type Notify func(error, time.Duration)

type Operation

type Operation func() error

type Provider

type Provider func(ctx context.Context) Backoff

func NewProvider

func NewProvider(cfg *Config) Provider

NewProvider returns a backoff provider based on the config on input. If no valid input is provided, a no retry backoff provider is returned instead.

type StopBackoff

type StopBackoff struct {
	backoff.BackOff
}

func NewStopBackoff

func NewStopBackoff() *StopBackoff

func (*StopBackoff) Retry

func (sbo *StopBackoff) Retry(op Operation) error

func (*StopBackoff) RetryNotify

func (sbo *StopBackoff) RetryNotify(op Operation, notify Notify) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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