retry

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, opts Options, fn RetryableFunc) (interface{}, error)

Execute performs the retryable function with the configured retry logic

Types

type Config

type Config struct {
	MaxRetries      int
	BaseDelay       time.Duration
	MaxDelay        time.Duration
	BackoffMultiple float64
}

Config holds the configuration for retry logic

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a sensible default retry configuration

type ErrorChecker

type ErrorChecker func(err error, statusCode int, responseBody []byte) bool

ErrorChecker defines a function that determines if an error should trigger a retry

type Logger

type Logger func(message string, args ...interface{})

Logger defines a function for logging retry attempts

type Options

type Options struct {
	Config       Config
	ErrorChecker ErrorChecker
	Logger       Logger
	APIName      string
}

Options configures retry behavior

type RetryExhaustedError

type RetryExhaustedError struct {
	APIName        string
	MaxAttempts    int
	LastStatusCode int
	LastResponse   []byte
}

RetryExhaustedError represents an error when all retry attempts have been exhausted

func (*RetryExhaustedError) Error

func (e *RetryExhaustedError) Error() string

type RetryableFunc

type RetryableFunc func(attempt int) (result interface{}, statusCode int, responseBody []byte, err error)

RetryableFunc defines a function that can be retried

Jump to

Keyboard shortcuts

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