Documentation ¶
Index ¶
Constants ¶
const ( // DefaultIdleConnsPerHost the default value set for http.Transport.MaxIdleConnsPerHost. DefaultIdleConnsPerHost = 64 // DefaultCloseIdleConnsPeriod the default period at which the idle connections are forcibly // closed. DefaultCloseIdleConnsPeriod = 20 * time.Second )
Variables ¶
var ( // ErrEmptyBackendList is used when the list of beckends is empty ErrEmptyBackendList = errors.New("can not elect backend, Backends empty") // ErrZeroWeight is used when there a zero value weight was given ErrZeroWeight = errors.New("invalid backend, weight 0 given") // ErrCannotElectBackend is used a backend cannot be elected ErrCannotElectBackend = errors.New("cant elect backend") )
var ( // ErrUnsupportedAlgorithm is used when an unsupported algorithm is given ErrUnsupportedAlgorithm = errors.New("unsupported balancing algorithm") )
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
Balancer holds the load balancer methods for many different algorithms
func NewBalancer ¶
NewBalancer creates a new Balancer based on balancing strategy
type Definition ¶
type Definition struct { PreserveHost bool `bson:"preserve_host" json:"preserve_host" mapstructure:"preserve_host"` ListenPath string `bson:"listen_path" json:"listen_path" mapstructure:"listen_path" valid:"required~proxy.listen_path is required,urlpath"` Upstreams *Upstreams `bson:"upstreams" json:"upstreams" mapstructure:"upstreams"` InsecureSkipVerify bool `bson:"insecure_skip_verify" json:"insecure_skip_verify" mapstructure:"insecure_skip_verify"` StripPath bool `bson:"strip_path" json:"strip_path" mapstructure:"strip_path"` AppendPath bool `bson:"append_path" json:"append_path" mapstructure:"append_path"` EnableLoadBalancing bool `bson:"enable_load_balancing" json:"enable_load_balancing" mapstructure:"enable_load_balancing"` Methods []string `bson:"methods" json:"methods"` Hosts []string `bson:"hosts" json:"hosts"` }
Definition defines proxy rules for a route
func NewDefinition ¶
func NewDefinition() *Definition
NewDefinition creates a new Proxy Definition with default values
func (*Definition) IsBalancerDefined ¶
func (d *Definition) IsBalancerDefined() bool
IsBalancerDefined checks if load balancer is defined
func (*Definition) Validate ¶
func (d *Definition) Validate() (bool, error)
Validate validates proxy data
type InChain ¶
type InChain []router.Constructor
InChain typed array for inbound plugin sequence, normally this is a middleware chain
func NewInChain ¶
func NewInChain(in ...router.Constructor) InChain
NewInChain variadic constructor for inbound plugin sequence
type OutChain ¶
type OutChain []OutLink
OutChain typed array for outbound plugin sequence
func NewOutChain ¶
NewOutChain variadic constructor for outbound plugin sequence
type Params ¶
type Params struct { // StatsClient defines the stats client for tracing StatsClient client.Client // When set, the proxy will skip the TLS verification on outgoing requests. InsecureSkipVerify bool // Same as net/http.Transport.MaxIdleConnsPerHost, but the default // is 64. This value supports scenarios with relatively few remote // hosts. When the routing table contains different hosts in the // range of hundreds, it is recommended to set this options to a // lower value. IdleConnectionsPerHost int // Defines the time period of how often the idle connections are // forcibly closed. The default is 12 seconds. When set to less than // 0, the proxy doesn't force closing the idle connections. CloseIdleConnsPeriod time.Duration // The Flush interval for copying upgraded connections FlushInterval time.Duration Outbound OutChain }
Params initialization options.
type Register ¶
Register handles the register of proxies into the chosen router. It also handles the conversion from a proxy to an http.HandlerFunc
func NewRegister ¶
NewRegister creates a new instance of Register
func (*Register) UpdateRouter ¶
UpdateRouter updates the reference to the router. This is useful to reload the mux
type RoundrobinBalancer ¶
type RoundrobinBalancer struct {
// contains filtered or unexported fields
}
RoundrobinBalancer balancer
func NewRoundrobinBalancer ¶
func NewRoundrobinBalancer() *RoundrobinBalancer
NewRoundrobinBalancer creates a new instance of Roundrobin
type Route ¶
type Route struct { Proxy *Definition Inbound InChain Outbound OutChain }
Route is the container for a proxy and it's handlers
func JSONUnmarshalRoute ¶
JSONUnmarshalRoute decodes route struct from JSON
func NewRouteWithInOut ¶
func NewRouteWithInOut(proxy *Definition, inbound InChain, outbound OutChain) *Route
NewRouteWithInOut creates an instance of Route with inbound and outbound handlers
func (*Route) AddInbound ¶
func (r *Route) AddInbound(in ...router.Constructor)
AddInbound adds inbound middlewares
func (*Route) AddOutbound ¶
AddOutbound adds outbound middlewares
func (*Route) JSONMarshal ¶
JSONMarshal encodes route struct to JSON
type Target ¶
type Target struct { Target string `bson:"target" json:"target" valid:"url,required"` Weight int `bson:"weight" json:"weight"` }
Target is an ip address/hostname with a port that identifies an instance of a backend service
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport construct holding plugin sequences
func NewTransport ¶
NewTransport creates a new instance of Transport
func NewTransportWithParams ¶
NewTransportWithParams creates a new instance of Transport with the given params
type Upstreams ¶
type Upstreams struct { Balancing string `bson:"balancing" json:"balancing"` Targets []*Target `bson:"targets" json:"targets"` }
Upstreams represents a collection of targets where the requests will go to
type WeightBalancer ¶
type WeightBalancer struct{}
WeightBalancer balancer
func NewWeightBalancer ¶
func NewWeightBalancer() *WeightBalancer
NewWeightBalancer creates a new instance of Roundrobin