retry

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[T any](ctx context.Context, maxAttempts int, strategy Strategy, op func() (T, error)) (T, error)

func Do2

func Do2[T, U any](ctx context.Context, maxAttempts int, strategy Strategy, op func() (T, U, error)) (T, U, error)

Types

type ErrFailedPermanently

type ErrFailedPermanently struct {
	LastErr error
	// contains filtered or unexported fields
}

func (*ErrFailedPermanently) Error

func (e *ErrFailedPermanently) Error() string

func (*ErrFailedPermanently) Unwrap

func (e *ErrFailedPermanently) Unwrap() error

type ExponentialStrategy

type ExponentialStrategy struct {
	Min       time.Duration
	Max       time.Duration
	MaxJitter time.Duration
}

func (*ExponentialStrategy) Duration

func (e *ExponentialStrategy) Duration(attempt int) time.Duration

type FixedStrategy

type FixedStrategy struct {
	Dur time.Duration
}

func (*FixedStrategy) Duration

func (f *FixedStrategy) Duration(attempt int) time.Duration

type Strategy

type Strategy interface {
	Duration(attempt int) time.Duration
}

func Exponential

func Exponential() Strategy

func Fixed

func Fixed(dur time.Duration) Strategy

Jump to

Keyboard shortcuts

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