retry

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 4 Imported by: 64

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient() *retryablehttp.Client

NewHTTPClient returns a retryable HTTP client

Types

type AbortableAction

type AbortableAction func(attempt uint) (error, bool)

AbortableAction ...

type Action

type Action func(attempt uint) error

Action ...

type HTTPLogAdaptor

type HTTPLogAdaptor struct{}

HTTPLogAdaptor adapts the retryablehttp.Logger interface to the go-utils logger.

func (*HTTPLogAdaptor) Printf

func (*HTTPLogAdaptor) Printf(fmtStr string, vars ...interface{})

Printf implements the retryablehttp.Logger interface

type Model

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

Model ...

func Times

func Times(retry uint) *Model

Times ...

func Wait

func Wait(waitTime time.Duration) *Model

Wait ...

func (*Model) Times

func (Model *Model) Times(retry uint) *Model

Times ...

func (Model) Try

func (Model Model) Try(action Action) error

Try continues executing the supplied action while this action parameter returns an error and the configured number of times has not been reached. Otherwise, it stops and returns the last received error.

func (Model) TryWithAbort

func (Model Model) TryWithAbort(action AbortableAction) error

TryWithAbort continues executing the supplied action while this action parameter returns an error, a false bool value and the configured number of times has not been reached. Returning a true value from the action aborts the retry loop.

Good for retrying actions which can return a mix of retryable and non-retryable failures.

func (*Model) Wait

func (Model *Model) Wait(waitTime time.Duration) *Model

Wait ...

Jump to

Keyboard shortcuts

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