httpx

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: Apache-2.0 Imports: 6 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResilientRoundTripper

type ResilientRoundTripper struct {
	// RoundTripper the wrapped RoundTripper.
	http.RoundTripper

	// ShouldRetry defines a strategy for retries.
	ShouldRetry RetryPolicy

	MaxInterval    time.Duration
	MaxElapsedTime time.Duration
}

ResilientRoundTripper wraps a RoundTripper and retries requests on failure.

func NewDefaultResilientRoundTripper

func NewDefaultResilientRoundTripper(
	maxInterval time.Duration,
	maxElapsedTime time.Duration,
) *ResilientRoundTripper

NewDefaultResilientRoundTripper returns a new ResilientRoundTripper with defaults.

func NewResilientRoundTripper

func NewResilientRoundTripper(
	roundTripper http.RoundTripper,
	maxInterval time.Duration,
	maxElapsedTime time.Duration,
) *ResilientRoundTripper

NewResilientRoundTripper returns a new ResilientRoundTripper.

func (*ResilientRoundTripper) RoundTrip

func (rt *ResilientRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction, returning a Response for the provided Request.

func (*ResilientRoundTripper) WithShouldRetry

func (rt *ResilientRoundTripper) WithShouldRetry(policy RetryPolicy) *ResilientRoundTripper

WithShouldRetry sets a RetryPolicy.

type RetryPolicy

type RetryPolicy func(*http.Response, error) (retry bool)

RetryPolicy returns true if the request should be retried.

func LoggedShouldRetry

func LoggedShouldRetry(l logrus.FieldLogger) RetryPolicy

LoggedShouldRetry returns a RetryPolicy that logs erros.

Jump to

Keyboard shortcuts

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