Documentation ¶
Index ¶
- Constants
- func DefaultClient() *http.Client
- func DefaultPooledClient() *http.Client
- func DefaultPooledTransport() *http.Transport
- func DefaultRetryPolicy(resp *http.Response, err error) (bool, error)
- func DefaultTransport() *http.Transport
- func NewRequest(method, url string, body io.ReadSeeker) (*http.Request, error)
- type Backoff
- type BackoffFunc
- type CheckRetry
- type Client
- type ClientConfig
- type HttpClient
- func (c *HttpClient) Do(req *http.Request) (*http.Response, error)
- func (c *HttpClient) Get(url string) (*http.Response, error)
- func (c *HttpClient) Head(url string) (*http.Response, error)
- func (c *HttpClient) Post(url string, contentType string, body io.ReadSeeker) (*http.Response, error)
- func (c *HttpClient) PostForm(url string, data url.Values) (*http.Response, error)
- func (c *HttpClient) QuietMode()
- func (c *HttpClient) SetBackoff(bc Backoff)
- func (c *HttpClient) SetRetries(retry int)
- func (c *HttpClient) TurnOffMetrics()
- type HystrixClient
- func (c *HystrixClient) Do(req *http.Request) (*http.Response, error)
- func (c *HystrixClient) Get(url string) (*http.Response, error)
- func (c *HystrixClient) Head(url string) (*http.Response, error)
- func (c *HystrixClient) Post(url string, contentType string, body io.ReadSeeker) (*http.Response, error)
- func (c *HystrixClient) PostForm(url string, data url.Values) (*http.Response, error)
- func (c *HystrixClient) SetFallbackFunc(fbf func(err error) error)
- type HystrixCommandConfig
- type LenReader
- type Metrics
Constants ¶
const ( DefaultMaxHttpRetries = 1 DefaultTimeout = 100 * time.Millisecond )
const (
DEFAULT_PROM_METRICS_NAMESPACE = "boomerang"
)
const (
DefaultMaxHystrixRetries = 1
)
Variables ¶
This section is empty.
Functions ¶
func DefaultClient ¶
DefaultClient returns a new http.Client with similar default values to http.Client, but with a non-shared Transport, idle connections disabled, and keepalives disabled.
func DefaultPooledClient ¶
DefaultPooledClient returns a new http.Client with similar default values to http.Client, but with a shared Transport. 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 DefaultPooledTransport ¶
DefaultPooledTransport returns a new http.Transport with similar default values to http.DefaultTransport. Do not use this for transient transports as it can leak file descriptors over time. Only use this for transports that will be re-used for the same host(s).
func DefaultRetryPolicy ¶
DefaultRetryPolicy provides a default callback for Client.CheckRetry, which will retry on connection errors and server errors.
func DefaultTransport ¶
DefaultTransport returns a new http.Transport with similar default values to http.DefaultTransport, but with idle connections and keepalives disabled.
func NewRequest ¶
Types ¶
type Backoff ¶
func NewBackoffFunc ¶
func NewBackoffFunc(f BackoffFunc) Backoff
func NewConstantBackoff ¶
NewConstanctBackoff returns an instance of ConstantBackoff
func NewExponentialBackoff ¶
NewExponentialBackoff returns an instance of ExponentialBackoff
type BackoffFunc ¶
func (BackoffFunc) NextInterval ¶
func (b BackoffFunc) NextInterval(retry int) time.Duration
type Client ¶
type Client interface { Get(url string) (*http.Response, error) Head(url string) (*http.Response, error) Post(url string, contentType string, body io.ReadSeeker) (*http.Response, error) PostForm(url string, data url.Values) (*http.Response, error) Do(req *http.Request) (*http.Response, error) }
Client Is a generic HTTP client interface
func DefaultHttpClient ¶
func DefaultHttpClient(config *ClientConfig) Client
type ClientConfig ¶
type HttpClient ¶
type HttpClient struct { Logger *log.Logger // Customer logger instance. Backoff Backoff // CheckRetry specifies the policy for handling retries, and is called // after each request. The default policy is DefaultRetryPolicy. CheckRetry CheckRetry MaxRetries int // To explicitly state if no metrics are to be recorded for this client RecordMetrics bool MetricsCtx Metrics // contains filtered or unexported fields }
func NewHttpClient ¶
func NewHttpClient(config *ClientConfig) *HttpClient
func (*HttpClient) Post ¶
func (c *HttpClient) Post(url string, contentType string, body io.ReadSeeker) (*http.Response, error)
func (*HttpClient) QuietMode ¶
func (c *HttpClient) QuietMode()
func (*HttpClient) SetBackoff ¶
func (c *HttpClient) SetBackoff(bc Backoff)
func (*HttpClient) SetRetries ¶
func (c *HttpClient) SetRetries(retry int)
func (*HttpClient) TurnOffMetrics ¶
func (c *HttpClient) TurnOffMetrics()
type HystrixClient ¶
type HystrixClient struct { Logger *log.Logger // Customer logger instance. Backoff Backoff // CheckRetry specifies the policy for handling retries, and is called // after each request. The default policy is DefaultRetryPolicy. CheckRetry CheckRetry MaxRetries int // contains filtered or unexported fields }
func NewHystrixClient ¶
func NewHystrixClient(timeout time.Duration, hc HystrixCommandConfig) *HystrixClient
func (*HystrixClient) Post ¶
func (c *HystrixClient) Post(url string, contentType string, body io.ReadSeeker) (*http.Response, error)
func (*HystrixClient) SetFallbackFunc ¶
func (c *HystrixClient) SetFallbackFunc(fbf func(err error) error)
type HystrixCommandConfig ¶
type HystrixCommandConfig struct { Timeout int `json:"timeout"` MaxConcurrentRequests int `json:"max_concurrent_requests"` RequestVolumeThreshold int `json:"request_volume_threshold"` SleepWindow int `json:"sleep_window"` ErrorPercentThreshold int `json:"error_percent_threshold"` CommandName string Transport *http.Transport }