Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do(ctx context.Context, task func(context.Context) error, backoff Backoff, checker Checker) error
Do retries `task` function until it returns nil error. If task return an error, checker checks if the retry is needed afeter waitng by waiter.
func NewHTTPTransport ¶
func NewHTTPTransport(base http.RoundTripper, checker HTTPChecker, backoff HTTPBackoff) http.RoundTripper
NewHTTPTransport returns a new http.RoundTripper instance for given checker and backoff configurations on top of base http.RoundTripper
Types ¶
type Backoff ¶
Backoff is an interface to implement backoff algorithm
func ConstBackoff ¶
ConstBackoff return a Backoff to return a constant time.Duration backoff given by `t`
type Checker ¶
Checker is an interface to check if a retry is needed or not.
func MaxRetries ¶
MaxRetries returns a Checker to check the number of retries is less than max.
type HTTPBackoff ¶
HTTPBackoff is an http version of Backoff
func HTTPConstBackoff ¶
func HTTPConstBackoff(t time.Duration) HTTPBackoff
HTTPConstBackoff is a http version of ConstBackoff
type HTTPChecker ¶
HTTPChecker is an http version of Checker
func HTTPAnd ¶
func HTTPAnd(checkers ...HTTPChecker) HTTPChecker
HTTPAnd is a AND combination of multiple HTTPChecker instances.
func HTTPMaxRetry ¶
func HTTPMaxRetry(max int) HTTPChecker
HTTPMaxRetry is an http version of MaxRetry
func HTTPResponseChecker ¶
func HTTPResponseChecker(f func(resp *http.Response) bool) HTTPChecker
HTTPResponseChecker returns a HTTPChecker that checks *http.Response for retries
func HTTPServerErrorChecker ¶
func HTTPServerErrorChecker() HTTPChecker
HTTPServerErrorChecker returns a HTTPChecker that needs retries when http status code >= 500
type HTTPTransport ¶
type HTTPTransport struct { Base http.RoundTripper Checker HTTPChecker Backoff HTTPBackoff }
HTTPTransport is a type for http.Transport with retry