retry

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package retry provides utilities for retrying operations 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 RetryableFunc) error

Do executes the function with retries according to the config.

func DoWithNotify

func DoWithNotify(ctx context.Context, cfg *Config, fn RetryableFunc, notify func(error, time.Duration)) error

DoWithNotify executes the function with retries and calls notify on each retry.

func NonRetryable

func NonRetryable(err error) error

NonRetryable wraps an error to make it non-retryable

func Retryable

func Retryable(err error) error

Retryable wraps an error to make it retryable

Types

type Config

type Config struct {
	MaxRetries     int
	InitialBackoff time.Duration
	MaxBackoff     time.Duration
	Multiplier     float64
	Jitter         float64 // 0.0-1.0, fraction of backoff to randomize (e.g. 0.25 = +/-25%)
}

Config represents retry configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default retry configuration

type RetryableError

type RetryableError interface {
	error
	IsRetryable() bool
}

RetryableError indicates whether an error is retryable

type RetryableFunc

type RetryableFunc func() error

RetryableFunc is a function that can be retried

Jump to

Keyboard shortcuts

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