retry

package
v0.0.0-...-687f649 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interrput

func Interrput() error

func IsInterrupt

func IsInterrupt(err error) bool

func Permanent

func Permanent(err error) error

Permanent makes the given error a permanent failure that stops the Retry loop immediately.

func Retry

func Retry(op func() error, timeout time.Duration) error

Retry the given operation until it succeeds, has a permanent failure or times out.

func RetryWithContext

func RetryWithContext(ctx context.Context, op func(ctx context.Context) error, timeout time.Duration, minAttempts ...int) error

RetryWithContext retries the given operation until it succeeds, has a permanent failure or times out. The timeout is the minimum between the timeout of the context and the given timeout. The context given to the operation will have a timeout of a percentage of the overall timeout. The percentage is calculated from the given minimum number of attempts. If the given minimum number of attempts is 3, the timeout of each `op` call if the overall timeout / 3. The default minimum number of attempts is 2.

Types

type Timeout

type Timeout func() error

func NewTimeout

func NewTimeout(t Timeout) Timeout

func (Timeout) Timeout

func (t Timeout) Timeout(interval, timeout time.Duration) error

type TimeoutError

type TimeoutError struct {
}

func (TimeoutError) Error

func (i TimeoutError) Error() string

Jump to

Keyboard shortcuts

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