retry

package
v0.57.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: AGPL-3.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TryAgain = false
	Stop     = true
)

Variables

This section is empty.

Functions

func Try

func Try(ctx context.Context, f func(context.Context) bool, attempts int, delay time.Duration) (ok bool)

Try will call the function f until it returns true or the context is done. If attempts is negative, Try will try forever.

func Try1

func Try1[T any](ctx context.Context, f func(context.Context) (T, bool), attempts int, delay time.Duration) (res T)

Try1 is a helper function that simplifies the common case of retrying a function that returns a single value.

func Try1Err

func Try1Err[T any](ctx context.Context, f func(context.Context) (T, error), attempts int, delay time.Duration) (res T, err error)

Try1Err is a helper function that simplifies the common case of retrying a function that returns a single value and an error.

func Try2

func Try2[T1, T2 any](ctx context.Context, f func(context.Context) (T1, T2, bool), attempts int, delay time.Duration) (res1 T1, res2 T2)

Try2 is a helper function that simplifies the common case of retrying a function that returns two values.

func Try2Err

func Try2Err[T1, T2 any](ctx context.Context, f func(context.Context) (T1, T2, error), attempts int, delay time.Duration) (res1 T1, res2 T2, err error)

Try2Err is a helper function that simplifies the common case of retrying a function that returns two values and an error.

func TryErr

func TryErr(ctx context.Context, f func(context.Context) error, attempts int, delay time.Duration) (err error)

TryErr will call the function f until it returns no error or the context is done. If attempts is negative, TryErr will try forever.

Types

This section is empty.

Jump to

Keyboard shortcuts

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