Documentation
¶
Overview ¶
* Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
* Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0
Index ¶
- type HTTPClientConfiguration
- type IClient
- type PooledClient
- func (c *PooledClient) Close() error
- func (c *PooledClient) Delete(url string) (*http.Response, error)
- func (c *PooledClient) Do(req *http.Request) (*http.Response, error)
- func (c *PooledClient) Get(url string) (*http.Response, error)
- func (c *PooledClient) Head(url string) (*http.Response, error)
- func (c *PooledClient) Post(url, bodyType string, body interface{}) (*http.Response, error)
- func (c *PooledClient) PostForm(url string, data url.Values) (*http.Response, error)
- func (c *PooledClient) Put(url string, rawBody interface{}) (*http.Response, error)
- func (c *PooledClient) StandardClient() *http.Client
- type RetryableClient
- func (c *RetryableClient) Close() error
- func (c *RetryableClient) Delete(url string) (*http.Response, error)
- func (c *RetryableClient) Do(req *http.Request) (*http.Response, error)
- func (c *RetryableClient) Get(url string) (*http.Response, error)
- func (c *RetryableClient) Head(url string) (*http.Response, error)
- func (c *RetryableClient) Post(url, bodyType string, body interface{}) (*http.Response, error)
- func (c *RetryableClient) PostForm(url string, data url.Values) (*http.Response, error)
- func (c *RetryableClient) Put(url string, rawBody interface{}) (*http.Response, error)
- func (c *RetryableClient) StandardClient() *http.Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPClientConfiguration ¶ added in v1.2.0
type HTTPClientConfiguration struct { MaxConnsPerHost int `mapstructure:"max_connections_per_host"` MaxIdleConns int `mapstructure:"max_idle_connections"` MaxIdleConnsPerHost int `mapstructure:"max_idle_connections_per_host"` IdleConnTimeout time.Duration `mapstructure:"timeout_idle_connection"` TLSHandshakeTimeout time.Duration `mapstructure:"timeout_tls_handshake"` ExpectContinueTimeout time.Duration `mapstructure:"timeout_expect_continue"` }
func DefaultHTTPClientConfiguration ¶ added in v1.2.0
func DefaultHTTPClientConfiguration() *HTTPClientConfiguration
Default values similar to https://github.com/hashicorp/go-cleanhttp/blob/6d9e2ac5d828e5f8594b97f88c4bde14a67bb6d2/cleanhttp.go#L23
func FastHTTPClientConfiguration ¶ added in v1.2.0
func FastHTTPClientConfiguration() *HTTPClientConfiguration
Default values similar to https://github.com/valyala/fasthttp/blob/81fc96827033a5ee92d8a098ab1cdb9827e1eb8d/client.go
func (*HTTPClientConfiguration) Validate ¶ added in v1.2.0
func (cfg *HTTPClientConfiguration) Validate() error
type IClient ¶
type IClient interface { io.Closer // Get is a convenience helper for doing simple GET requests. Get(url string) (*http.Response, error) // Head is a convenience method for doing simple HEAD requests. Head(url string) (*http.Response, error) // Post is a convenience method for doing simple POST requests. Post(url, bodyType string, body interface{}) (*http.Response, error) // PostForm is a convenience method for doing simple POST operations using // pre-filled url.Values form data. PostForm(url string, data url.Values) (*http.Response, error) // StandardClient returns a stdlib *http.Client with a custom Transport, which // shims in a *retryablehttp.Client for added retries. StandardClient() *http.Client // Perform a PUT request. Put(url string, rawBody interface{}) (*http.Response, error) // Perform a DELETE request. Delete(url string) (*http.Response, error) // Perform a generic request with exponential backoff Do(req *http.Request) (*http.Response, error) }
IClient provides a familiar HTTP client interface with automatic retries and exponential backoff.
func NewConfigurableRetryableClient ¶ added in v1.2.0
func NewConfigurableRetryableClient(cfg *HTTPClientConfiguration) IClient
NewRetryableClient creates a new http client which will retry failed requests with exponential backoff
func NewDefaultPooledClient ¶ added in v1.2.0
func NewDefaultPooledClient() IClient
NewDefaultPooledClient returns a new HTTP client with similar default values to
http.Client, but with a shared Transport.
func NewFastPooledClient ¶ added in v1.2.0
func NewFastPooledClient() IClient
NewFastPooledClient returns a new HTTP client with similar default values to
fast http client https://github.com/valyala/fasthttp.
func NewPooledClient ¶ added in v1.2.0
func NewPooledClient(cfg *HTTPClientConfiguration) IClient
NewPooledClient returns a new HTTP client using the configuration passed as argument.
Do not use this function for transient clients as it can leak file descriptors over time. Only use this for clients that will be re-used for the same host(s).
func NewRetryableClient ¶
func NewRetryableClient() IClient
NewRetryableClient creates a new http client which will retry failed requests with exponential backoff
type PooledClient ¶ added in v1.2.0
type PooledClient struct {
// contains filtered or unexported fields
}
PooledClient is an HTTP client similar to
http.Client, but with a shared Transport and different configuration values. It is based on https://github.com/hashicorp/go-cleanhttp which ensures the client configuration is only set for the current use case and not the whole project (i.e. no global variable)
func (*PooledClient) Close ¶ added in v1.2.0
func (c *PooledClient) Close() error
func (*PooledClient) Delete ¶ added in v1.2.0
func (c *PooledClient) Delete(url string) (*http.Response, error)
func (*PooledClient) Get ¶ added in v1.2.0
func (c *PooledClient) Get(url string) (*http.Response, error)
func (*PooledClient) Head ¶ added in v1.2.0
func (c *PooledClient) Head(url string) (*http.Response, error)
func (*PooledClient) Post ¶ added in v1.2.0
func (c *PooledClient) Post(url, bodyType string, body interface{}) (*http.Response, error)
func (*PooledClient) Put ¶ added in v1.2.0
func (c *PooledClient) Put(url string, rawBody interface{}) (*http.Response, error)
func (*PooledClient) StandardClient ¶ added in v1.2.0
func (c *PooledClient) StandardClient() *http.Client
type RetryableClient ¶
type RetryableClient struct {
// contains filtered or unexported fields
}
func (*RetryableClient) Close ¶ added in v1.2.0
func (c *RetryableClient) Close() error
func (*RetryableClient) Delete ¶
func (c *RetryableClient) Delete(url string) (*http.Response, error)
func (*RetryableClient) Post ¶
func (c *RetryableClient) Post(url, bodyType string, body interface{}) (*http.Response, error)
func (*RetryableClient) Put ¶
func (c *RetryableClient) Put(url string, rawBody interface{}) (*http.Response, error)
func (*RetryableClient) StandardClient ¶
func (c *RetryableClient) StandardClient() *http.Client