Documentation ¶
Index ¶
- Variables
- type ErrorOptions
- type LoadBalancer
- func (lb *LoadBalancer) AddUpstream(u *Upstream)
- func (lb *LoadBalancer) ClearUpstreams()
- func (lb *LoadBalancer) Healthy() bool
- func (lb *LoadBalancer) Metrics() LoadBalancerMetrics
- func (lb *LoadBalancer) NextUpstream(ctx *requestContext) (result *Upstream, err error)
- func (lb *LoadBalancer) OnError(ctx *requestContext, w http.ResponseWriter, r *http.Request, err error)
- func (lb *LoadBalancer) OnErrorResponse(ctx *requestContext, r *http.Response) http.Handler
- func (lb *LoadBalancer) PickUpstream(ctx *requestContext) (result *Upstream, err error)
- func (lb *LoadBalancer) RemoveUpstream(u *Upstream)
- func (lb *LoadBalancer) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (lb *LoadBalancer) SetLogger(logger *xlog.Logger)
- func (lb *LoadBalancer) Upstreams() (us []*Upstream)
- type LoadBalancerMetrics
- type Options
- type StateType
- type Strategy
- type SuppressedHttpError
- type Upstream
- type UpstreamMetrics
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoHealthyUpstreams = errors.New("no healthy upstreams")
View Source
var StateEnum = util.NewEnum(map[StateType]string{ StateSticky: "sticky", StateNone: "none", })
View Source
var StrategyEnum = util.NewEnum(map[Strategy]string{ StrategyLeastConn: "least", StrategyRandom: "random", StrategyHash: "hash", StrategyRoundRobin: "round-robin", })
Functions ¶
This section is empty.
Types ¶
type ErrorOptions ¶
type ErrorOptions struct { Handle *vhttp.Subhandler `yaml:"handle,omitempty"` // The error handler. Limit rate.Limit `yaml:"limit,omitempty"` // The rate limit. }
type LoadBalancer ¶
type LoadBalancer struct { Options `yaml:",inline"` // contains filtered or unexported fields }
func (*LoadBalancer) AddUpstream ¶
func (lb *LoadBalancer) AddUpstream(u *Upstream)
func (*LoadBalancer) ClearUpstreams ¶
func (lb *LoadBalancer) ClearUpstreams()
func (*LoadBalancer) Healthy ¶
func (lb *LoadBalancer) Healthy() bool
func (*LoadBalancer) Metrics ¶
func (lb *LoadBalancer) Metrics() LoadBalancerMetrics
func (*LoadBalancer) NextUpstream ¶
func (lb *LoadBalancer) NextUpstream(ctx *requestContext) (result *Upstream, err error)
func (*LoadBalancer) OnError ¶
func (lb *LoadBalancer) OnError(ctx *requestContext, w http.ResponseWriter, r *http.Request, err error)
func (*LoadBalancer) OnErrorResponse ¶
func (lb *LoadBalancer) OnErrorResponse(ctx *requestContext, r *http.Response) http.Handler
func (*LoadBalancer) PickUpstream ¶
func (lb *LoadBalancer) PickUpstream(ctx *requestContext) (result *Upstream, err error)
func (*LoadBalancer) RemoveUpstream ¶
func (lb *LoadBalancer) RemoveUpstream(u *Upstream)
func (*LoadBalancer) ServeHTTP ¶
func (lb *LoadBalancer) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*LoadBalancer) SetLogger ¶
func (lb *LoadBalancer) SetLogger(logger *xlog.Logger)
func (*LoadBalancer) Upstreams ¶
func (lb *LoadBalancer) Upstreams() (us []*Upstream)
type LoadBalancerMetrics ¶
type LoadBalancerMetrics struct {
Upstreams []UpstreamMetrics `json:"upstreams,omitempty"`
}
type Options ¶
type Options struct { Retry retry.Policy `yaml:",inline"` // The retry policy. Strategy Strategy `yaml:"strat,omitempty"` // The load balancing strategy. State StateType `yaml:"state,omitempty"` // The session kind. Error4xx *ErrorOptions `yaml:"4xx,omitempty"` // The error handler for 4xx responses. Error5xx *ErrorOptions `yaml:"5xx,omitempty"` // The error handler for 5xx responses. Error404 *ErrorOptions `yaml:"404,omitempty"` // The error handler for 404 responses. }
type StateType ¶
type StateType uint8
func (StateType) MarshalText ¶
func (*StateType) UnmarshalText ¶
type SuppressedHttpError ¶
func (SuppressedHttpError) Error ¶
func (err SuppressedHttpError) Error() string
type Upstream ¶
type Upstream struct { Address string Healthy atomic.Bool LoadFactor atomic.Int32 ReverseProxy httputil.ReverseProxy // Metrics RequestCount atomic.Uint32 ErrorCount atomic.Uint32 ServerErrorCount atomic.Uint32 ClientErrorCount atomic.Uint32 }
func NewHttpUpstream ¶
func (*Upstream) Metrics ¶
func (u *Upstream) Metrics() UpstreamMetrics
func (*Upstream) SetHealthy ¶
type UpstreamMetrics ¶
type UpstreamMetrics struct { Address string `json:"address,omitempty"` Healthy bool `json:"healthy,omitempty"` LoadFactor int32 `json:"load_factor,omitempty"` RequestCount uint32 `json:"request_count,omitempty"` ErrorCount uint32 `json:"error_count,omitempty"` ServerErrorCount uint32 `json:"server_error_count,omitempty"` ClientErrorCount uint32 `json:"client_error_count,omitempty"` }
Click to show internal directories.
Click to hide internal directories.