retry

package
v0.0.0-...-1593278 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 8

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 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 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