retry

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// timeout configuration constants
	CONFIG_IS_RETRYABLE = "IsRetryable"

	// requesrt errors
	ERR_NO_SUCH_HOST = "dial tcp: lookup"
)
View Source
const (
	// timeout configuration constants
	CONFIG_THROTTLE         = "Throttle"
	CONFIG_THROTTLE_DEFAULT = 1 * time.Second
)
View Source
const (
	// timeout configuration constants
	CONFIG_TIMEOUT         = "Timeout"
	CONFIG_TIMEOUT_DEFAULT = 2 * time.Minute
)
View Source
const (
	// name of the configuration
	CONFIG_MAX_RETRIES = "MaxRetries"
)
View Source
const (
	// Wait configuration constants
	CONFIG_UNTIL = "Until"
)

Variables

This section is empty.

Functions

func IsRetryableDefault

func IsRetryableDefault(err error) bool

IsRetryableDefault

func IsRetryableNoOp

func IsRetryableNoOp(err error) bool

IsRetryableNoOp always retries

Types

type Config

type Config interface {
	String() string
	Value() interface{}
}

type Retry

type Retry struct {
	// contains filtered or unexported fields
}

func New

func New() *Retry

New returns a new instance of Retry with default values

func (*Retry) Do

func (r *Retry) Do(req *http.Request, do func(*http.Request) (*http.Response, error)) (*http.Response, error)

Do runs a given do function with a given request -> do(req)

func (*Retry) SetIsRetryable

func (c *Retry) SetIsRetryable(f ...func(err error) bool) *Retry

SetIsRetryable sets functions that determin if an error can be retried or not

func (*Retry) SetMaxRetries

func (c *Retry) SetMaxRetries(r int) *Retry

SetMaxRetries sets the maximum retries

func (*Retry) SetThrottle

func (c *Retry) SetThrottle(d time.Duration) *Retry

SetThrottle sets the duration to wait between calls

func (*Retry) SetTimeout

func (c *Retry) SetTimeout(d time.Duration) *Retry

SetTimeout sets the maximum run duration

func (*Retry) SetUntil added in v0.3.0

func (c *Retry) SetUntil(f ...UntilFn) *Retry

SetUntil sets functions that determin if the response given is the expected response this functionality is useful, for example, when waiting for an API status to be ready

type UntilFn added in v0.3.0

type UntilFn func(*http.Response) (bool, error)

Jump to

Keyboard shortcuts

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