retry

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package retry provides configurable retry logic with exponential backoff.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

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

Do executes fn with retries.

func DoWithResult

func DoWithResult[T any](ctx context.Context, cfg Config, fn func() (T, error)) (T, error)

DoWithResult executes fn with retries and returns a result.

func IsRetryable

func IsRetryable(err error) bool

IsRetryable returns true for errors that warrant a retry.

Types

type Config

type Config struct {
	MaxRetries int
	BaseDelay  time.Duration
	MaxDelay   time.Duration
	Multiplier float64
	Retryable  func(error) bool
}

Config configures retry behavior.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

Jump to

Keyboard shortcuts

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