Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultRetryTransport = retry.Transport{ Delay: retry.Constant(100 * time.Millisecond), Retry: retry.All(Context(), retry.Max(9), retry.EOF(), retry.Net(), retry.Temporary(), RetryCodes(408, 502, 503, 504)), }
DefaultRetryTransport is used as default retry mechanism
Deprecated: Use NewDefaultRetryTransport() instead. The DefaultRetryTransport will be removed in future versions. It is broken as its global nature means that the DefaultRetryTransport.Next http.RoundTripper is shared among all users. In previous versions of this package this would mean that the last user to call RetryRoundTripper.SetTransport() defines the shared DefaultRetryTransport.Next http.RoundTripper. This was unknowingly changed in v0.1.12. After that this still is at least a race condition issue as we can have multiple simultaneous usages, that all set DefaultRetryTransport.Next and indirectly call this shared state via DefaultRetryTransport.RoundTrip().
Functions ¶
func NewDefaultRetryTransport ¶ added in v0.1.13
NewDefaultRetryTransport returns a new default retry transport.
func RetryCodes ¶
RetryCodes retries when the status code is one of the provided list
Types ¶
type ChainableRoundTripper ¶
type ChainableRoundTripper interface { // Transport returns the RoundTripper to make HTTP requests Transport() http.RoundTripper // SetTransport sets the RoundTripper to make HTTP requests SetTransport(http.RoundTripper) // RoundTrip executes a single HTTP transaction via Transport() RoundTrip(*http.Request) (*http.Response, error) }
ChainableRoundTripper models a chainable round tripper
type JaegerRoundTripper ¶
type JaegerRoundTripper struct {
// contains filtered or unexported fields
}
JaegerRoundTripper implements a chainable round tripper for tracing
func (*JaegerRoundTripper) SetTransport ¶
func (l *JaegerRoundTripper) SetTransport(rt http.RoundTripper)
SetTransport sets the RoundTripper to make HTTP requests
func (*JaegerRoundTripper) Transport ¶
func (l *JaegerRoundTripper) Transport() http.RoundTripper
Transport returns the RoundTripper to make HTTP requests
type LoggingRoundTripper ¶
type LoggingRoundTripper struct {
// contains filtered or unexported fields
}
LoggingRoundTripper implements a chainable round tripper for logging
func (*LoggingRoundTripper) SetTransport ¶
func (l *LoggingRoundTripper) SetTransport(rt http.RoundTripper)
SetTransport sets the RoundTripper to make HTTP requests
func (*LoggingRoundTripper) Transport ¶
func (l *LoggingRoundTripper) Transport() http.RoundTripper
Transport returns the RoundTripper to make HTTP requests
type RequestSourceRoundTripper ¶ added in v0.1.12
type RequestSourceRoundTripper struct { SourceName string // contains filtered or unexported fields }
RequestSourceRoundTripper implements a chainable round tripper for setting the Request-Source header
func (*RequestSourceRoundTripper) RoundTrip ¶ added in v0.1.12
RoundTrip executes a single HTTP transaction via Transport()
func (*RequestSourceRoundTripper) SetTransport ¶ added in v0.1.12
func (l *RequestSourceRoundTripper) SetTransport(rt http.RoundTripper)
SetTransport sets the RoundTripper to make HTTP requests
func (*RequestSourceRoundTripper) Transport ¶ added in v0.1.12
func (l *RequestSourceRoundTripper) Transport() http.RoundTripper
Transport returns the RoundTripper to make HTTP requests
type RetryRoundTripper ¶
type RetryRoundTripper struct { RetryTransport *retry.Transport // contains filtered or unexported fields }
RetryRoundTripper implements a chainable round tripper for retrying requests
func NewDefaultRetryRoundTripper ¶
func NewDefaultRetryRoundTripper() *RetryRoundTripper
NewDefaultRetryRoundTripper returns a retry round tripper with a NewDefaultRetryTransport() as transport.
func NewRetryRoundTripper ¶
func NewRetryRoundTripper(rt *retry.Transport) *RetryRoundTripper
NewRetryRoundTripper returns a retry round tripper with the specified retry transport.
func (*RetryRoundTripper) SetTransport ¶
func (l *RetryRoundTripper) SetTransport(rt http.RoundTripper)
SetTransport sets the RoundTripper to make HTTP requests
func (*RetryRoundTripper) Transport ¶
func (l *RetryRoundTripper) Transport() http.RoundTripper
Transport returns the RoundTripper to make HTTP requests
type RoundTripperChain ¶
type RoundTripperChain struct {
// contains filtered or unexported fields
}
RoundTripperChain chains multiple chainable round trippers together.
func Chain ¶
func Chain(rt ...ChainableRoundTripper) *RoundTripperChain
Chain returns a round tripper chain with the specified chainable round trippers and http.DefaultTransport as transport. The transport can be overriden by using the Final method.
func NewDefaultTransportChain ¶
func NewDefaultTransportChain() *RoundTripperChain
NewDefaultTransportChain returns a transport chain with retry, jaeger and logging support. If not explicitly finalized via `Final` it uses `http.DefaultTransport` as finalizer.
func (*RoundTripperChain) Final ¶
func (c *RoundTripperChain) Final(t http.RoundTripper) *RoundTripperChain
Final sets the transport of the round tripper chain, which is used to make the actual request. Final should be called at the end of the chain. If not called, http.DefaultTransport is used. It returns the finalized round tripper chain.
func (*RoundTripperChain) RoundTrip ¶
RoundTrip calls all round trippers in the chain before executing the request.
func (*RoundTripperChain) Use ¶
func (c *RoundTripperChain) Use(rt ChainableRoundTripper) *RoundTripperChain
Use adds a chainable round tripper to the round tripper chain. It returns the updated round tripper chain.