client

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStrategyFallback = errors.New("fallback to next strategy")

Functions

func GetSchemeHostKey

func GetSchemeHostKey(urlString string) (string, error)

func RetryPolicy added in v0.4.0

func RetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)

RetryPolicy wraps retryablehttp.DefaultRetryPolicy and included additional logic: - checks for specific errors that indicate a fall-back to the next download strategy - checks for http.StatusBadGateway and http.StatusServiceUnavailable which also indicate a fall-back

Types

type HTTPClient

type HTTPClient struct {
	*http.Client
}

HTTPClient is a wrapper around http.Client that allows for limiting the number of concurrent connections per host utilizing a client pool. If the OptMaxConnPerHost option is not set, the client pool will not be used.

func NewHTTPClient added in v0.2.0

func NewHTTPClient(opts Options) *HTTPClient

NewHTTPClient factory function returns a new http.Client with the appropriate settings and can limit number of clients per host if the OptMaxConnPerHost option is set.

func (*HTTPClient) Do added in v0.2.0

func (c *HTTPClient) Do(req *http.Request) (*http.Response, error)

type Options added in v0.2.0

type Options struct {
	ForceHTTP2       bool
	MaxConnPerHost   int
	MaxRetries       int
	ConnectTimeout   time.Duration
	ResolveOverrides map[string]string
}

Jump to

Keyboard shortcuts

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