retrypolicy

package
v0.0.0-...-762ab57 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MPL-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const Done time.Duration = -1

Done is returned when CalculateNextDelay has reached it delay retry limit

Variables

View Source
var (
	// DefaultRetry a default policy
	DefaultRetry, _ = New(
		WithInitialInterval(50*time.Millisecond),
		WithBackoffCoefficient(2.0),
		WithMaximumInterval(10*time.Second),
		WithExpirationInterval(time.Minute),
		WithMaximumAttempts(10),
	)

	// NoRetry policy to be used if no retries are required
	NoRetry, _ = New(
		WithInitialInterval(0),
		WithBackoffCoefficient(0),
		WithMaximumInterval(0),
		WithExpirationInterval(0),
		WithMaximumAttempts(0),
	)
)

Functions

This section is empty.

Types

type Option

type Option func(policy *policy) error

Option func to build retry policy

func WithBackoffCoefficient

func WithBackoffCoefficient(backoffCoefficient float64) Option

WithBackoffCoefficient sets the coefficient used to calculate next interval

func WithExpirationInterval

func WithExpirationInterval(expirationInterval time.Duration) Option

WithExpirationInterval sets the maximum elapsed time an operation should be tried for

func WithInitialInterval

func WithInitialInterval(initialInterval time.Duration) Option

WithInitialInterval sets the initial interval

func WithMaximumAttempts

func WithMaximumAttempts(maximumAttempts int) Option

WithMaximumAttempts sets the maximum number of times an operation will be tried

func WithMaximumInterval

func WithMaximumInterval(maximumInterval time.Duration) Option

WithMaximumInterval sets the maximum time that can be calculated for next interval

type Retry

type Retry interface {
	// CalculateNextDelay implementations should return the next delay interval
	CalculateNextDelay() time.Duration
}

Retry api

func New

func New(options ...Option) (Retry, error)

New return a new instance of retry policy

Directories

Path Synopsis
Package mockretrypolicy is a generated GoMock package.
Package mockretrypolicy is a generated GoMock package.

Jump to

Keyboard shortcuts

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