retry

package
v0.0.217 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRetryConfig = RetryConfig{
	MaxRetries:  5,
	InitialWait: 1 * time.Second,
	MaxWait:     60 * time.Second,
	Factor:      2.0,
}

DefaultRetryConfig provides sensible defaults for retry operations

Functions

func Is429Error

func Is429Error(err error) bool

Is429Error is retained for existing API providers. Despite its historical name, it now delegates to the shared transient classifier so every provider receives the same retry coverage.

func IsTransient added in v0.0.207

func IsTransient(err error) bool

IsTransient reports whether an error is safe to retry without changing the request. It deliberately excludes ordinary client/configuration failures so those remain fast-fail. Providers use this shared classifier to avoid drift between HTTP APIs and local agent CLIs.

func WithRetry

func WithRetry(operation func() (interface{}, error), shouldRetry func(error) bool, config RetryConfig) (interface{}, error)

WithRetry executes the given function with retry logic It will retry the function if it returns an error that matches the shouldRetry function

Types

type RetryConfig

type RetryConfig struct {
	MaxRetries  int           // Maximum number of retry attempts
	InitialWait time.Duration // Initial wait time before first retry
	MaxWait     time.Duration // Maximum wait time between retries
	Factor      float64       // Exponential backoff factor
}

RetryConfig holds configuration for retry operations

func (RetryConfig) DebugLog

func (c RetryConfig) DebugLog(format string, args ...interface{})

DebugLog logs debug information if verbose mode is enabled

func (RetryConfig) Log

func (c RetryConfig) Log(format string, args ...interface{})

Log prints a message regardless of debug mode

Jump to

Keyboard shortcuts

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