retry

package
v1.201.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnexpectedError = errors.New("unexpected end of retry loop")

Functions

func DefaultConfig

func DefaultConfig() schema.RetryConfig

DefaultConfig returns a sensible default configuration.

func Do

func Do(ctx context.Context, config *schema.RetryConfig, fn Func) error

Do is a convenience function that creates an executor and runs the function.

func With7Params

func With7Params[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any](ctx context.Context,
	config *schema.RetryConfig,
	fn func(T1, T2, T3, T4, T5, T6, T7) error, a T1, b T2, c T3, d T4, e T5, f T6, g T7,
) error

func WithPredicate

func WithPredicate(ctx context.Context, config *schema.RetryConfig, fn Func, shouldRetry func(error) bool) error

WithPredicate allows you to specify which errors should trigger a retry.

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor handles the retry logic.

func New

func New(config schema.RetryConfig) *Executor

New creates a new retry executor with the given config.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, fn Func) error

Execute runs the function with retry logic.

func (*Executor) ExecuteWithPredicate

func (e *Executor) ExecuteWithPredicate(ctx context.Context, fn Func, shouldRetry func(error) bool) error

type Func

type Func func() error

Func represents a function that can be retried.

type MaxElapsedTimeError

type MaxElapsedTimeError struct {
	MaxElapsedTime time.Duration
}

func (MaxElapsedTimeError) Error

func (e MaxElapsedTimeError) Error() string

Jump to

Keyboard shortcuts

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