retry

package
v1.17.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retry

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

Retry calls the passed function until it returns nil, or the passed timeout expires.

Retries once per second until timeout expires. Returns how long the function retried, and the last error if the command timed out.

func WithContext added in v1.16.0

func WithContext(ctx context.Context, fn func() error) (time.Duration, error)

WithContext calls the passed function until it returns nil, or the provided context is closed. Make sure to use a context that eventually closes.

Retries once per second until context closes. Returns how long the function retried, and the last error if the context was closed.

Types

type TerminalError

type TerminalError struct {
	Cause error
}

TerminalError will stop a Retry loop if returned.

func NewTerminalError

func NewTerminalError(cause error) *TerminalError

NewTerminalError constructs a new TerminalError

func (*TerminalError) Error

func (te *TerminalError) Error() string

Error returns the error message

func (*TerminalError) Unwrap

func (te *TerminalError) Unwrap() error

Unwrap returns the cause of this TerminalError

Jump to

Keyboard shortcuts

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