bricks: github.com/pace/bricks/http/transport Index | Files

package transport

import "github.com/pace/bricks/http/transport"

Index

Package Files

attempt_round_tripper.go chainable.go circuit_breaker_tripper.go default_transport.go dump_round_tripper.go errors.go jaeger_round_tripper.go locale_round_tripper.go logging_round_tripper.go request_id.go request_source_round_tripper.go retry_round_tripper.go

Constants

const (
    DumpRoundTripperOptionRequest     = "request"
    DumpRoundTripperOptionResponse    = "response"
    DumpRoundTripperOptionRequestHEX  = "request-hex"
    DumpRoundTripperOptionResponseHEX = "response-hex"
    DumpRoundTripperOptionBody        = "body"
)

Variables

var (
    ErrRetryFailed   = errors.New("failed after maximum number of retries")
    ErrCircuitBroken = errors.New("circuit to remote host is open")
)

func Context Uses

func Context() retry.Retryer

Context aborts if the request's context is finished

func NewCircuitBreakerTripper Uses

func NewCircuitBreakerTripper(settings gobreaker.Settings) *circuitBreakerTripper

func NewDefaultCircuitBreakerTripper Uses

func NewDefaultCircuitBreakerTripper(name string) *circuitBreakerTripper

func NewDefaultRetryTransport Uses

func NewDefaultRetryTransport() *retry.Transport

NewDefaultRetryTransport returns a new default retry transport.

func RetryCodes Uses

func RetryCodes(codes ...int) retry.Retryer

RetryCodes retries when the status code is one of the provided list

type ChainableRoundTripper Uses

type ChainableRoundTripper interface {
    http.RoundTripper

    // Transport returns the RoundTripper to make HTTP requests
    Transport() http.RoundTripper
    // SetTransport sets the RoundTripper to make HTTP requests
    SetTransport(http.RoundTripper)
}

ChainableRoundTripper models a chainable round tripper

type DumpRoundTripper Uses

type DumpRoundTripper struct {
    DumpRequest     bool
    DumpResponse    bool
    DumpRequestHEX  bool
    DumpResponseHEX bool
    DumpBody        bool
    // contains filtered or unexported fields
}

DumpRoundTripper dumps requests and responses in one log event. This is not part of te request logger to be able to filter dumps more easily

func NewDumpRoundTripper Uses

func NewDumpRoundTripper(options ...string) *DumpRoundTripper

NewDumpRoundTripper return the roundtripper with configured options

func NewDumpRoundTripperEnv Uses

func NewDumpRoundTripperEnv() *DumpRoundTripper

NewDumpRoundTripperEnv creates a new RoundTripper based on the configuration that is passed via environment variables

func (DumpRoundTripper) AnyEnabled Uses

func (l DumpRoundTripper) AnyEnabled() bool

AnyEnabled returns true if any logging is enabled

func (*DumpRoundTripper) RoundTrip Uses

func (l *DumpRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction via Transport()

func (*DumpRoundTripper) SetTransport Uses

func (l *DumpRoundTripper) SetTransport(rt http.RoundTripper)

SetTransport sets the RoundTripper to make HTTP requests

func (*DumpRoundTripper) Transport Uses

func (l *DumpRoundTripper) Transport() http.RoundTripper

Transport returns the RoundTripper to make HTTP requests

type DumpRoundTripperOption Uses

type DumpRoundTripperOption string

type JaegerRoundTripper Uses

type JaegerRoundTripper struct {
    // contains filtered or unexported fields
}

JaegerRoundTripper implements a chainable round tripper for tracing

func (*JaegerRoundTripper) RoundTrip Uses

func (l *JaegerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a HTTP request with distributed tracing

func (*JaegerRoundTripper) SetTransport Uses

func (l *JaegerRoundTripper) SetTransport(rt http.RoundTripper)

SetTransport sets the RoundTripper to make HTTP requests

func (*JaegerRoundTripper) Transport Uses

func (l *JaegerRoundTripper) Transport() http.RoundTripper

Transport returns the RoundTripper to make HTTP requests

type LocaleRoundTripper Uses

type LocaleRoundTripper struct {
    // contains filtered or unexported fields
}

LocaleRoundTripper implements a chainable round tripper for locale forwarding

func (*LocaleRoundTripper) RoundTrip Uses

func (l *LocaleRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a HTTP request with logging

func (*LocaleRoundTripper) SetTransport Uses

func (l *LocaleRoundTripper) SetTransport(rt http.RoundTripper)

SetTransport sets the RoundTripper to make HTTP requests

func (*LocaleRoundTripper) Transport Uses

func (l *LocaleRoundTripper) Transport() http.RoundTripper

Transport returns the RoundTripper to make HTTP requests

type LoggingRoundTripper Uses

type LoggingRoundTripper struct {
    // contains filtered or unexported fields
}

LoggingRoundTripper implements a chainable round tripper for logging

func (*LoggingRoundTripper) RoundTrip Uses

func (l *LoggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a HTTP request with logging

func (*LoggingRoundTripper) SetTransport Uses

func (l *LoggingRoundTripper) SetTransport(rt http.RoundTripper)

SetTransport sets the RoundTripper to make HTTP requests

func (*LoggingRoundTripper) Transport Uses

func (l *LoggingRoundTripper) Transport() http.RoundTripper

Transport returns the RoundTripper to make HTTP requests

type RequestIDRoundTripper Uses

type RequestIDRoundTripper struct {
    SourceName string
    // contains filtered or unexported fields
}

RequestIDRoundTripper implements a chainable round tripper for setting the Request-Source header

func (*RequestIDRoundTripper) RoundTrip Uses

func (l *RequestIDRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction via Transport()

func (*RequestIDRoundTripper) SetTransport Uses

func (l *RequestIDRoundTripper) SetTransport(rt http.RoundTripper)

SetTransport sets the RoundTripper to make HTTP requests

func (*RequestIDRoundTripper) Transport Uses

func (l *RequestIDRoundTripper) Transport() http.RoundTripper

Transport returns the RoundTripper to make HTTP requests

type RequestSourceRoundTripper Uses

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 Uses

func (l *RequestSourceRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction via Transport()

func (*RequestSourceRoundTripper) SetTransport Uses

func (l *RequestSourceRoundTripper) SetTransport(rt http.RoundTripper)

SetTransport sets the RoundTripper to make HTTP requests

func (*RequestSourceRoundTripper) Transport Uses

func (l *RequestSourceRoundTripper) Transport() http.RoundTripper

Transport returns the RoundTripper to make HTTP requests

type RetryRoundTripper Uses

type RetryRoundTripper struct {
    // contains filtered or unexported fields
}

RetryRoundTripper implements a chainable round tripper for retrying requests

func NewDefaultRetryRoundTripper Uses

func NewDefaultRetryRoundTripper() *RetryRoundTripper

NewDefaultRetryRoundTripper returns a retry round tripper with a NewDefaultRetryTransport() as transport.

func NewRetryRoundTripper Uses

func NewRetryRoundTripper(rt *retry.Transport) *RetryRoundTripper

NewRetryRoundTripper returns a retry round tripper with the specified retry transport.

func (*RetryRoundTripper) RoundTrip Uses

func (l *RetryRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a HTTP request with retrying

func (*RetryRoundTripper) SetTransport Uses

func (l *RetryRoundTripper) SetTransport(rt http.RoundTripper)

SetTransport sets the RoundTripper to make HTTP requests

func (*RetryRoundTripper) Transport Uses

func (l *RetryRoundTripper) Transport() http.RoundTripper

Transport returns the RoundTripper to make HTTP requests

type RoundTripperChain Uses

type RoundTripperChain struct {
    // contains filtered or unexported fields
}

RoundTripperChain chains multiple chainable round trippers together.

func Chain Uses

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 Uses

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 Uses

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 Uses

func (c *RoundTripperChain) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip calls all round trippers in the chain before executing the request.

func (*RoundTripperChain) Use Uses

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.

Package transport imports 18 packages (graph) and is imported by 1 packages. Updated 2020-08-06. Refresh now. Tools for package owners.