retry

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 3 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

Do calls fn up to maxAttempts times, sleeping with exponential backoff and jitter between attempts. Returns the last error if all attempts fail.

Types

type Option

type Option func(*config)

Option configures retry behavior.

func WithInitialBackoff

func WithInitialBackoff(d time.Duration) Option

WithInitialBackoff sets the initial backoff duration (default 1s).

func WithMaxAttempts

func WithMaxAttempts(n int) Option

WithMaxAttempts sets the maximum number of attempts (default 3).

func WithMaxBackoff

func WithMaxBackoff(d time.Duration) Option

WithMaxBackoff sets the maximum backoff duration (default 30s).

func WithMultiplier

func WithMultiplier(m float64) Option

WithMultiplier sets the backoff multiplier (default 2.0).

Jump to

Keyboard shortcuts

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