Documentation
¶
Index ¶
- Constants
- func DefaultTransport() http.RoundTripper
- func DisableHTTPCache()
- func EnableHTTPCache()
- func NewPlainClient() *http.Client
- func NewRetryClient() *http.Client
- func NewThrottledRetryClient(limitPeriod time.Duration, requestCount int) *http.Client
- func ProxyOnlyTransport() http.RoundTripper
- type HTTPClient
- type MockClient
Constants ¶
const RetryCount = 3
Variables ¶
This section is empty.
Functions ¶
func DefaultTransport ¶ added in v0.115.0
func DefaultTransport() http.RoundTripper
DefaultTransport returns a RoundTripper with retry and proxy support. When HTTP caching is enabled via EnableHTTPCache, GET responses are served from cache: retryTransport -> cachingTransport -> otelhttp -> http.Transport.
func DisableHTTPCache ¶ added in v0.116.0
func DisableHTTPCache()
DisableHTTPCache deactivates the HTTP cache so that new clients no longer use it. Already-created clients may still hold a reference to the previous cache until they are garbage collected. Safe to call even if caching was never enabled.
func EnableHTTPCache ¶ added in v0.116.0
func EnableHTTPCache()
EnableHTTPCache activates in-memory caching of GET responses for all HTTP clients created via this package after this call. Call once before pipeline execution begins.
func NewPlainClient ¶ added in v0.115.0
NewPlainClient returns an HTTP client with proxy support but no retry.
func NewRetryClient ¶ added in v0.84.1
func NewThrottledRetryClient ¶ added in v0.115.0
NewThrottledRetryClient returns an HTTP client with rate limiting wrapping retry + proxy.
func ProxyOnlyTransport ¶ added in v0.115.0
func ProxyOnlyTransport() http.RoundTripper
ProxyOnlyTransport returns a RoundTripper with proxy support but no retry. Use when the caller handles its own retry (e.g. go-containerregistry) or for non-idempotent operations (e.g. OAuth token exchange) where retry is unsafe.
Types ¶
type HTTPClient ¶
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
Get(url string) (*http.Response, error)
}
HTTPClient interface to define the contract of ALL http client to be used (http package or mocks)
type MockClient ¶ added in v0.19.0
MockClient is a stub implementation of an http.Client with a custom `Do` method