Documentation
¶
Index ¶
- func IsHedgedRequest(r *http.Request) bool
- func NewClient(timeout time.Duration, upto int, client *http.Client) (*http.Client, error)
- func NewRoundTripper(timeout time.Duration, upto int, rt http.RoundTripper) (http.RoundTripper, error)
- type ErrorFormatFunc
- type MultiError
- type Stats
- type StatsSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsHedgedRequest ¶ added in v0.6.2
IsHedgedRequest reports when a request is hedged.
func NewClient ¶
NewClient returns a new http.Client which implements hedged requests pattern. Given Client starts a new request after a timeout from previous request. Starts no more than upto requests.
func NewRoundTripper ¶
func NewRoundTripper(timeout time.Duration, upto int, rt http.RoundTripper) (http.RoundTripper, error)
NewRoundTripper returns a new http.RoundTripper which implements hedged requests pattern. Given RoundTripper starts a new request after a timeout from previous request. Starts no more than upto requests.
Types ¶
type ErrorFormatFunc ¶ added in v0.2.0
ErrorFormatFunc is called by MultiError to return the list of errors as a string.
type MultiError ¶ added in v0.2.0
type MultiError struct {
Errors []error
ErrorFormatFn ErrorFormatFunc
}
MultiError is an error type to track multiple errors. This is used to accumulate errors in cases and return them as a single "error". Inspired by https://github.com/hashicorp/go-multierror
func (*MultiError) Error ¶ added in v0.2.0
func (e *MultiError) Error() string
func (*MultiError) ErrorOrNil ¶ added in v0.2.0
func (e *MultiError) ErrorOrNil() error
ErrorOrNil returns an error if there are some.
func (*MultiError) String ¶ added in v0.2.0
func (e *MultiError) String() string
type Stats ¶ added in v0.6.0
type Stats struct {
// contains filtered or unexported fields
}
Stats object that can be queried to obtain certain metrics and get better observability.
func NewClientAndStats ¶ added in v0.6.0
func NewClientAndStats(timeout time.Duration, upto int, client *http.Client) (*http.Client, *Stats, error)
NewClientAndStats returns a new http.Client which implements hedged requests pattern And Stats object that can be queried to obtain client's metrics. Given Client starts a new request after a timeout from previous request. Starts no more than upto requests.
func NewRoundTripperAndStats ¶ added in v0.6.0
func NewRoundTripperAndStats(timeout time.Duration, upto int, rt http.RoundTripper) (http.RoundTripper, *Stats, error)
NewRoundTripperAndStats returns a new http.RoundTripper which implements hedged requests pattern And Stats object that can be queried to obtain client's metrics. Given RoundTripper starts a new request after a timeout from previous request. Starts no more than upto requests.
func (*Stats) ActualRoundTrips ¶ added in v0.6.0
ActualRoundTrips returns count of requests that were actually sent.
func (*Stats) CanceledByUserRoundTrips ¶ added in v0.6.0
CanceledByUserRoundTrips returns count of requests that were canceled by user, using request context.
func (*Stats) CanceledSubRequests ¶ added in v0.6.0
CanceledSubRequests returns count of hedged sub-requests that were canceled by transport.
func (*Stats) FailedRoundTrips ¶ added in v0.6.0
FailedRoundTrips returns count of requests that failed.
func (*Stats) RequestedRoundTrips ¶ added in v0.6.0
RequestedRoundTrips returns count of requests that were requested by client.
func (*Stats) Snapshot ¶ added in v0.6.0
func (s *Stats) Snapshot() StatsSnapshot
Snapshot of the stats.
type StatsSnapshot ¶ added in v0.6.0
type StatsSnapshot struct {
RequestedRoundTrips uint64 // count of requests that were requested by client
ActualRoundTrips uint64 // count of requests that were actually sent
FailedRoundTrips uint64 // count of requests that failed
CanceledByUserRoundTrips uint64 // count of requests that were canceled by user, using request context
CanceledSubRequests uint64 // count of hedged sub-requests that were canceled by transport
}
StatsSnapshot is a snapshot of Stats.