Documentation ¶
Index ¶
Constants ¶
const ( StatusCodeRetryOther = http.StatusPermanentRedirect StatusCodeThrottle = http.StatusTooManyRequests )
Variables ¶
This section is empty.
Functions ¶
func DrainBody ¶
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 StatusCodeFromError ¶
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, maxRetries int) *RequestRetrier
NewRequestRetrier creates a new request retrier. Regardless of maxRetries, mesh URIs will never be retried.
func (*RequestRetrier) GetNextURI ¶ added in v2.3.0
func (r *RequestRetrier) GetNextURI(ctx context.Context, resp *http.Response, respErr error) (string, error)
GetNextURI returns the next URI a client should use, or an error if there's no suitable URI. This should only be called after validating that there's a suitable URI to use via ShouldGetNextURI, in which case an error will never be returned.
func (*RequestRetrier) ShouldGetNextURI ¶ added in v2.3.0
func (r *RequestRetrier) ShouldGetNextURI(resp *http.Response, respErr error) bool
ShouldGetNextURI returns true if GetNextURI has never been called or if the request and its corresponding error indicate the request should be retried.