retry

package
v0.0.202 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 6 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 checks if the error is a rate limit (429) error

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