retry

package
v0.0.0-...-572c485 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

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

Do will run function with retry mechanism. fn is the func to run. Option can control the retry times and timeout.

func Handle

func Handle(ctx context.Context, fn func() (bool, error), opts ...Option) error

Do will run function with retry mechanism. fn is the func to run, return err and shouldRetry flag. Option can control the retry times and timeout.

func IsRecoverable

func IsRecoverable(err error) bool

IsRecoverable is used to judge whether the error is wrapped by unrecoverableError.

func Unrecoverable

func Unrecoverable(err error) error

Unrecoverable method wrap an error to unrecoverableError. This will make retry quick return.

Types

type Option

type Option func(*config)

Option is used to config the retry function.

func Attempts

func Attempts(attempts uint) Option

Attempts is used to config the max retry times.

func MaxSleepTime

func MaxSleepTime(maxSleepTime time.Duration) Option

MaxSleepTime is used to config the max interval time of each execution.

func RetryErr

func RetryErr(isRetryErr func(err error) bool) Option

func Sleep

func Sleep(sleep time.Duration) Option

Sleep is used to config the initial interval time of each execution.

Jump to

Keyboard shortcuts

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