Documentation ¶
Index ¶
- func NewBalancedReverseProxy(def *Definition, balancer balancer.Balancer, statsClient client.Client) *httputil.ReverseProxy
- type Definition
- type Duration
- type ForwardingTimeouts
- type Register
- type RegisterOption
- func WithFlushInterval(d time.Duration) RegisterOption
- func WithIdleConnPurgeTicker(d time.Duration) RegisterOption
- func WithIdleConnTimeout(d time.Duration) RegisterOption
- func WithIdleConnectionsPerHost(value int) RegisterOption
- func WithIsPublicEndpoint(b bool) RegisterOption
- func WithRouter(router router.Router) RegisterOption
- func WithStatsClient(statsClient client.Client) RegisterOption
- type RouterDefinition
- type Target
- type Targets
- type Upstreams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBalancedReverseProxy ¶
func NewBalancedReverseProxy(def *Definition, balancer balancer.Balancer, statsClient client.Client) *httputil.ReverseProxy
NewBalancedReverseProxy creates a reverse proxy that is load balanced
Types ¶
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"` Methods []string `bson:"methods" json:"methods"` Hosts []string `bson:"hosts" json:"hosts"` ForwardingTimeouts ForwardingTimeouts `bson:"forwarding_timeouts" json:"forwarding_timeouts" mapstructure:"forwarding_timeouts"` }
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 Duration ¶
Duration is the time.Duration that can be unmarshalled from JSON
func (*Duration) MarshalJSON ¶
MarshalJSON implements marshalling from JSON
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements unmarshalling from JSON
type ForwardingTimeouts ¶
type ForwardingTimeouts struct { DialTimeout Duration `bson:"dial_timeout" json:"dial_timeout"` ResponseHeaderTimeout Duration `bson:"response_header_timeout" json:"response_header_timeout"` }
ForwardingTimeouts contains timeout configurations for forwarding requests to the backend servers.
type Register ¶
type Register struct {
// contains filtered or unexported fields
}
Register handles the register of proxies into the chosen router. It also handles the conversion from a proxy to an http.HandlerFunc
func NewRegister ¶
func NewRegister(opts ...RegisterOption) *Register
NewRegister creates a new instance of Register
func (*Register) Add ¶
func (p *Register) Add(definition *RouterDefinition) error
Add register a new route
func (*Register) UpdateRouter ¶
UpdateRouter updates the reference to the router. This is useful to reload the mux
type RegisterOption ¶
type RegisterOption func(*Register)
RegisterOption represents the register options
func WithFlushInterval ¶
func WithFlushInterval(d time.Duration) RegisterOption
WithFlushInterval sets the Flush interval for copying upgraded connections
func WithIdleConnPurgeTicker ¶
func WithIdleConnPurgeTicker(d time.Duration) RegisterOption
WithIdleConnPurgeTicker purges idle connections on every interval if set this is done to prevent permanent keep-alive on connections with high ops
func WithIdleConnTimeout ¶
func WithIdleConnTimeout(d time.Duration) RegisterOption
WithIdleConnTimeout sets the maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
func WithIdleConnectionsPerHost ¶
func WithIdleConnectionsPerHost(value int) RegisterOption
WithIdleConnectionsPerHost sets idle connections per host option
func WithIsPublicEndpoint ¶
func WithIsPublicEndpoint(b bool) RegisterOption
WithIsPublicEndpoint adds trace metadata from incoming requests as parent span if set to false
func WithStatsClient ¶
func WithStatsClient(statsClient client.Client) RegisterOption
WithStatsClient sets stats client instance for proxy
type RouterDefinition ¶
type RouterDefinition struct { *Definition // contains filtered or unexported fields }
RouterDefinition represents an API that you want to proxy with internal router routines
func NewRouterDefinition ¶
func NewRouterDefinition(def *Definition) *RouterDefinition
NewRouterDefinition creates a new Proxy RouterDefinition from Proxy Definition
func (*RouterDefinition) AddMiddleware ¶
func (d *RouterDefinition) AddMiddleware(m router.Constructor)
AddMiddleware adds a middleware to a site's middleware stack.
func (*RouterDefinition) Middleware ¶
func (d *RouterDefinition) Middleware() []router.Constructor
Middleware returns s.middleware (useful for tests).
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 Targets ¶
type Targets []*Target
Targets is a set of target
func (Targets) ToBalancerTargets ¶
ToBalancerTargets returns the balancer expected type