httploc

package
Version: v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2014 License: Apache-2.0, Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

HTTP location with load balancing and pluggable middlewares

Index

Constants

View Source
const (
	DefaultHttpReadTimeout     = time.Duration(10) * time.Second
	DefaultHttpDialTimeout     = time.Duration(10) * time.Second
	DefaultTlsHandshakeTimeout = time.Duration(10) * time.Second
	DefaultKeepAlivePeriod     = time.Duration(30) * time.Second
	DefaultMaxIdleConnsPerHost = 16
)

Standard dial and read timeouts, can be overriden when supplying location

View Source
const (
	BalancerId = "__loadBalancer"
	RewriterId = "__rewriter"
)

Variables

This section is empty.

Functions

func NewTransport

func NewTransport(o TransportOptions) *http.Transport

Types

type HttpLocation

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

Location with built in failover and load balancing support

func NewLocation

func NewLocation(id string, loadBalancer loadbalance.LoadBalancer) (*HttpLocation, error)

func NewLocationWithOptions

func NewLocationWithOptions(id string, loadBalancer loadbalance.LoadBalancer, o Options) (*HttpLocation, error)

func (*HttpLocation) GetId

func (l *HttpLocation) GetId() string

func (*HttpLocation) GetLoadBalancer

func (l *HttpLocation) GetLoadBalancer() loadbalance.LoadBalancer

func (*HttpLocation) GetMiddlewareChain

func (l *HttpLocation) GetMiddlewareChain() *middleware.MiddlewareChain

func (*HttpLocation) GetObserverChain

func (l *HttpLocation) GetObserverChain() *middleware.ObserverChain

func (*HttpLocation) GetOptions

func (l *HttpLocation) GetOptions() Options

func (*HttpLocation) GetOptionsAndTransport

func (l *HttpLocation) GetOptionsAndTransport() (Options, *http.Transport)

func (*HttpLocation) RoundTrip

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

Round trips the request to one of the endpoints and returns the response.

func (*HttpLocation) SetOptions

func (l *HttpLocation) SetOptions(o Options) error

func (*HttpLocation) SetTransport

func (l *HttpLocation) SetTransport(t *http.Transport) error

type KeepAlive

type KeepAlive struct {
	// Keepalive period
	Period time.Duration
	// How many idle connections will be kept per host
	MaxIdleConnsPerHost int
}

type Limits

type Limits struct {
	MaxMemBodyBytes int64 // Maximum size to keep in memory before buffering to disk
	MaxBodyBytes    int64 // Maximum size of a request body in bytes
}

Limits contains various limits one can supply for a location.

type Options

type Options struct {
	Timeouts Timeouts
	// Controls KeepAlive settins for backend servers
	KeepAlive KeepAlive
	// Limits contains various limits one can supply for a location.
	Limits Limits
	// Predicate that defines when requests are allowed to failover
	FailoverPredicate threshold.Predicate
	// Used in forwarding headers
	Hostname string
	// In this case appends new forward info to the existing header
	TrustForwardHeader bool
	// Time provider (useful for testing purposes)
	TimeProvider timetools.TimeProvider
	// Transport gives a way to provide external transport that can be shared between multiple locations
	Transport *http.Transport
}

Additional options to control this location, such as timeouts

type Rewriter

type Rewriter struct {
	TrustForwardHeader bool
	Hostname           string
}

Rewriter is responsible for removing hop-by-hop headers, fixing encodings and content-length

func (*Rewriter) ProcessRequest

func (rw *Rewriter) ProcessRequest(r request.Request) (*http.Response, error)

func (*Rewriter) ProcessResponse

func (tl *Rewriter) ProcessResponse(r request.Request, a request.Attempt)

type Timeouts

type Timeouts struct {
	// Socket read timeout (before we receive the first reply header)
	Read time.Duration
	// Socket connect timeout
	Dial time.Duration
	// TLS handshake timeout
	TlsHandshake time.Duration
}

type TransportOptions

type TransportOptions struct {
	Timeouts  Timeouts
	KeepAlive KeepAlive
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL