retry

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(fn func() error, opts ...Option) error

func DoWithData

func DoWithData[T any](fn func() (T, error), opts ...Option) (T, error)

Types

type Backoff

type Backoff struct {
	// How long to wait before first retry
	InitialDelay time.Duration
	// Upper bound on backoff
	MaxDelay time.Duration
	// Factor with which to multiply backoff after a failed retry
	Factor float64
	// By how much to randomize backoff
	Jitter float64
}

func (*Backoff) Delay

func (b *Backoff) Delay(attempt int) time.Duration

type Config

type Config struct {
	// contains filtered or unexported fields
}

type Option

type Option func(*Config) error

func MaxAttempts

func MaxAttempts(n int) Option

func RetryIf

func RetryIf(fn func(error) bool) Option

func WithBackoff

func WithBackoff(b *Backoff) Option

func WithContext

func WithContext(ctx context.Context) Option

Jump to

Keyboard shortcuts

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