Documentation ¶
Overview ¶
Package try provides a set of functions to retry a function with a delay.
Index ¶
- func Do(tries int, delay time.Duration, fn func() error) (err error)
- func DoExponentialBackoff(tries int, delay time.Duration, multiplier time.Duration, ...) (err error)
- func DoExponentialBackoffWithContextAndResult[T any](parent context.Context, tries int, delay time.Duration, multiplier int, ...) (result T, err error)
- func DoExponentialBackoffWithResult[T any](tries int, delay time.Duration, multiplier int, maxBackoff time.Duration, ...) (result T, err error)
- func DoWithContextTimeout(parent context.Context, tries int, delay time.Duration, timeout time.Duration, ...) (err error)
- func DoWithContextTimeoutWithResult[T any](parent context.Context, tries int, delay time.Duration, timeout time.Duration, ...) (result T, err error)
- func DoWithResult[T any](tries int, delay time.Duration, fn func() (T, error)) (result T, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoExponentialBackoff ¶
func DoExponentialBackoff( tries int, delay time.Duration, multiplier time.Duration, maxBackoff time.Duration, fn func() error, ) (err error)
DoExponentialBackoff tries a function with exponential backoff.
func DoExponentialBackoffWithContextAndResult ¶ added in v0.4.0
func DoExponentialBackoffWithContextAndResult[T any]( parent context.Context, tries int, delay time.Duration, multiplier int, maxBackoff time.Duration, fn func(ctx context.Context) (T, error), ) (result T, err error)
DoExponentialBackoffWithContextAndResult performs an exponential backoff with context and returns a result
nolint: ireturn
func DoExponentialBackoffWithResult ¶
func DoExponentialBackoffWithResult[T any]( tries int, delay time.Duration, multiplier int, maxBackoff time.Duration, fn func() (T, error), ) (result T, err error)
DoExponentialBackoffWithResult performs an exponential backoff and return a result.
nolint: ireturn
func DoWithContextTimeout ¶
func DoWithContextTimeout( parent context.Context, tries int, delay time.Duration, timeout time.Duration, fn func(ctx context.Context, try int) error, ) (err error)
DoWithContextTimeout tries a function with context and timeout.
func DoWithContextTimeoutWithResult ¶
func DoWithContextTimeoutWithResult[T any]( parent context.Context, tries int, delay time.Duration, timeout time.Duration, verbose bool, fn func(ctx context.Context, try int) (T, error), ) (result T, err error)
DoWithContextTimeoutWithResult performs a function with context and returns a result.
nolint: ireturn
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.