Documentation
¶
Index ¶
- Constants
- func Try(ctx context.Context, f func(context.Context) bool, attempts int, ...) (ok bool)
- func Try1[T any](ctx context.Context, f func(context.Context) (T, bool), attempts int, ...) (res T)
- func Try1Err[T any](ctx context.Context, f func(context.Context) (T, error), attempts int, ...) (res T, err error)
- func Try2[T1, T2 any](ctx context.Context, f func(context.Context) (T1, T2, bool), attempts int, ...) (res1 T1, res2 T2)
- func Try2Err[T1, T2 any](ctx context.Context, f func(context.Context) (T1, T2, error), attempts int, ...) (res1 T1, res2 T2, err error)
- func TryErr(ctx context.Context, f func(context.Context) error, attempts int, ...) (err error)
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.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.