retry

package
v0.0.0-...-a345a4b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

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

Do execute the specified function at most maxTries times until it succeeds or got canceled

Types

type IsRetryable

type IsRetryable func(error) bool

IsRetryable checks the error is safe or worth to retry, eg. "context.Canceled" better not retry

type Operation

type Operation func() error

Operation is the action need to retry

type Option

type Option func(*retryOptions)

Option ...

func WithBackoffBaseDelay

func WithBackoffBaseDelay(delayInMs int64) Option

WithBackoffBaseDelay configures the initial delay, if delayInMs <= 0 "defaultBackoffBaseInMs" will be used

func WithBackoffMaxDelay

func WithBackoffMaxDelay(delayInMs int64) Option

WithBackoffMaxDelay configures the maximum delay, if delayInMs <= 0 "defaultBackoffCapInMs" will be used

func WithInfiniteTries

func WithInfiniteTries() Option

WithInfiniteTries configures to retry forever (math.MaxInt64 times) till success or got canceled

func WithIsRetryableErr

func WithIsRetryableErr(f IsRetryable) Option

WithIsRetryableErr configures the error should retry or not, if not set, retry by default

func WithMaxTries

func WithMaxTries(tries int64) Option

WithMaxTries configures maximum tries, if tries <= 0 "defaultMaxTries" will be used

Jump to

Keyboard shortcuts

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