internal

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCodeRetryOther             = http.StatusPermanentRedirect
	StatusCodeRetryTemporaryRedirect = http.StatusTemporaryRedirect
	StatusCodeThrottle               = http.StatusTooManyRequests
	StatusCodeUnavailable            = http.StatusServiceUnavailable
)

Variables

This section is empty.

Functions

func DrainBody

func DrainBody(resp *http.Response)

DrainBody reads then closes a response's body if it is non-nil. This function should be deferred before a response reference is discarded.

func LocationFromError added in v2.13.0

func LocationFromError(err error) (location string, ok bool)

LocationFromError retrieves the 'location' parameter from the provided werror. If the error is not a werror or does not have the location param, ok is false.

The default client error decoder sets the location parameter on its returned errors if the status code is 3xx and a location is set in the response header

func StatusCodeFromError

func StatusCodeFromError(err error) (statusCode int, ok bool)

StatusCodeFromError retrieves the 'statusCode' parameter from the provided werror. If the error is not a werror or does not have the statusCode param, ok is false.

The default client error decoder sets the statusCode parameter on its returned errors. Note that, if a custom error decoder is used, this function will only return a status code for the error if the custom decoder sets a 'statusCode' parameter on the error.

Types

type RequestRetrier added in v2.3.0

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

RequestRetrier manages URIs for an HTTP client, providing an API which determines whether requests should be retries and supplying the correct URL for the client to retry. In the case of servers in a service-mesh, requests will never be retried and the mesh URI will only be returned on the first call to GetNextURI

func NewRequestRetrier added in v2.3.0

func NewRequestRetrier(uris []string, retrier retry.Retrier, maxAttempts int) *RequestRetrier

NewRequestRetrier creates a new request retrier. Regardless of maxAttempts, mesh URIs will never be retried.

func (*RequestRetrier) GetNextURI added in v2.3.0

func (r *RequestRetrier) GetNextURI(resp *http.Response, respErr error) (uri string, isRelocated bool)

GetNextURI returns the next URI a client should use, or empty string if no suitable URI remaining to retry. isRelocated is true when the URI comes from a redirect's Location header. In this case, it already includes the request path.

Jump to

Keyboard shortcuts

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