backoffmiddleware

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const MaxRetriesInfinite = -1

MaxRetriesInfinite constant indicate that the middleware should never give up retrying

Variables

This section is empty.

Functions

func New

func New(config Config) endpoint.Middleware

New tries to execute @next.Process() until it succeeds. Each failure is followed by an exponentially increasing delay.

Types

type Config

type Config struct {
	// InitialDelay represents the delay after the first error, before adding
	// the spread
	InitialDelay time.Duration

	// MaxDelay represents the max delay after an error, before adding the
	// spread
	MaxDelay time.Duration

	// Spread is the percentage of the current delay that can be added as a
	// random term. For example, with a delay of 10s and 20% spread, the
	// calculated delay will be between 10s and 12s.
	Spread float64

	// Factor represents how bigger the next delay wil be in comparison to the
	// current one
	Factor float64

	// MaxRetries indicates how many times this middleware should retry.
	// SeverityRuntime errors are always retried and don't count . SeverityInput errors are never retried.
	MaxRetries int
}

Config contains the config for the exponential backoff retrier

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig returns a ready-to-use Config with sane defaults

Jump to

Keyboard shortcuts

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