retry

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCriteria

func DefaultCriteria(tc minds.ThreadContext, attempt int, err error) bool

DefaultCriteria retries on all errors.

Types

type BackoffStrategy

type BackoffStrategy func(attempt int) time.Duration

BackoffStrategy defines how delay increases between attempts.

func DefaultBackoff

func DefaultBackoff(delay time.Duration) BackoffStrategy

DefaultBackoff provides a simple constant delay.

type Criteria

type Criteria func(tc minds.ThreadContext, attempt int, err error) bool

Criteria defines when a retry should be attempted.

type Option

type Option func(*Options)

Option defines a retry configuration function.

func WithAttempts

func WithAttempts(attempts int) Option

WithAttempts configures max retry attempts.

func WithBackoff

func WithBackoff(strategy BackoffStrategy) Option

WithBackoff sets a custom backoff strategy.

func WithRetryCriteria

func WithRetryCriteria(criteria Criteria) Option

WithRetryCriteria sets a custom retry criteria.

func WithoutTimeoutPropagation

func WithoutTimeoutPropagation() Option

WithoutTimeoutPropagation disables context timeout propagation.

type Options

type Options struct {
	Attempts         int
	Backoff          BackoffStrategy
	ShouldRetry      Criteria
	PropagateTimeout bool
}

Options defines retry behavior.

func NewDefaultOptions

func NewDefaultOptions() *Options

NewDefaultOptions returns default retry options.

Jump to

Keyboard shortcuts

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