retry

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backoff

func Backoff(d time.Duration) time.Duration

func Do

func Do(ctx context.Context, retryableFunc RetryableFunc, opts ...Option) error

func Jitter

func Jitter(d time.Duration) time.Duration

Types

type AfterFunc

type AfterFunc func(time.Duration) <-chan time.Time

Function signature of time.After function

type Config

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

type DynamicAttemptsFunc

type DynamicAttemptsFunc func(attempt uint, attempts uint, err error) uint

Function signature of "dynamic attempts" function

type DynamicDelayFunc

type DynamicDelayFunc func(attempt uint, delay time.Duration, err error) time.Duration

Function signature of "dynamic delay" function

type OnRetryFunc

type OnRetryFunc func(attempt uint, err error) error

Function signature of "on retry" function

type Option

type Option func(*Config)

Option represents an option for retry.

func Attempts

func Attempts(attempts uint) Option

Attempts set count of retry. Setting to 0 will retry until the retried function succeeds. Default is 1 (one attampt) Number of attempts can be override by the dynamicAttempts function

func Delay

func Delay(delay time.Duration) Option

Delay set delay between retry. It can be override by the delayType function Default is 0 (no delay) Number of attempts can be override by the dynamicDelay function

func DynamicAttempts

func DynamicAttempts(dynamicAttempts DynamicAttemptsFunc) Option

DynamicAttempts dynamically set the number of attempts

func DynamicDelay

func DynamicDelay(dynamicDelay DynamicDelayFunc) Option

DynamicDelay dynamically set the delay between retries

func OnRetry

func OnRetry(onRetry OnRetryFunc) Option

OnRetry function callback are called each retry

func RetryIf

func RetryIf(retryIf RetryIfFunc) Option

RetryIf controls whether a retry should be attempted after an error (assuming there are any retry attempts remaining)

func WithAfter

func WithAfter(after AfterFunc) Option

WithAfter provides a way to swap out time.After implementations. This primarily is useful for mocking/testing, where you may not want to explicitly wait for a set duration for retries.

type RetryIfFunc

type RetryIfFunc func(attempt uint, err error) bool

Function signature of "retry if" function

type RetryableFunc

type RetryableFunc func() error

Function signature of retryable function

Jump to

Keyboard shortcuts

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