retry

package
v0.0.0-...-4e0b803 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(ctx context.Context, fn func(context.Context) error) error

Do wraps func with a backoff to retry.

func Infinite

func Infinite(ctx context.Context, fn func(context.Context) error) error

Infinite wraps func with a backoff to retry.

Types

type Option

type Option func(*Retry)

Option is retry option.

func WithBaseDelay

func WithBaseDelay(d time.Duration) Option

WithBaseDelay overrides the initial wait duration.

func WithJitter

func WithJitter(j float64) Option

WithJitter overrides the jitter factor.

func WithMaxDelay

func WithMaxDelay(d time.Duration) Option

WithMaxDelay overrides the max wait duration.

func WithMultiplier

func WithMultiplier(m float64) Option

WithMultiplier overrides the exponential factor.

func WithRetryable

func WithRetryable(r Retryable) Option

WithRetryable with retryable.

type Retry

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

Retry config.

func New

func New(attempts int, opts ...Option) *Retry

New new a retry with backoff.

func (*Retry) Do

func (r *Retry) Do(ctx context.Context, fn func(context.Context) error) error

Do wraps func with a backoff to retry.

type Retryable

type Retryable func(err error) bool

Retryable is used to judge whether an error is retryable or not.

Jump to

Keyboard shortcuts

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