retry

package
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBackoff

func WithBackoff[T any](ctx context.Context, config Config, operation func(context.Context) (T, error)) (T, error)

WithBackoff retries an operation with exponential backoff because hammering a service repeatedly is so last decade

Types

type Config

type Config struct {
	Attempts     int
	InitialDelay time.Duration
	MaxDelay     time.Duration
	Multiplier   float64
	RandomFactor float64
}

Config holds configuration for retry operations because sometimes you need more than just "try again and hope for the best"

func DefaultRetryConfig

func DefaultRetryConfig() Config

DefaultRetryConfig returns a configuration that's probably better than whatever you were going to come up with

Jump to

Keyboard shortcuts

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