Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendConfig ¶
type BackendConfig struct { Options // contains filtered or unexported fields }
BackendConfig HealthCheck configuration for a backend.
func NewBackendConfig ¶
func NewBackendConfig(options Options, backendName string) *BackendConfig
NewBackendConfig Instantiate a new BackendConfig.
type Balancer ¶
type Balancer interface { Servers() []*url.URL RemoveServer(u *url.URL) error UpsertServer(u *url.URL, options ...roundrobin.ServerOption) error }
Balancer is the set of operations required to manage the list of servers in a load-balancer.
type BalancerHandler ¶
type BalancerHandler interface { ServeHTTP(w http.ResponseWriter, req *http.Request) Balancer }
BalancerHandler includes functionality for load-balancing management.
type BalancerStatusHandler ¶ added in v2.5.0
type BalancerStatusHandler interface { BalancerHandler StatusUpdater }
BalancerStatusHandler is an http Handler that does load-balancing, and updates its parents of its status.
type Balancers ¶
type Balancers []Balancer
Balancers is a list of Balancers(s) that implements the Balancer interface.
func (Balancers) RemoveServer ¶
RemoveServer removes the given server from all the BalancerHandler, and updates the status of the server to "DOWN".
func (Balancers) UpsertServer ¶
func (b Balancers) UpsertServer(u *url.URL, options ...roundrobin.ServerOption) error
UpsertServer adds the given server to all the BalancerHandler, and updates the status of the server to "UP".
type HealthCheck ¶
type HealthCheck struct { Backends map[string]*BackendConfig // contains filtered or unexported fields }
HealthCheck struct.
func GetHealthCheck ¶
func GetHealthCheck(registry metrics.Registry) *HealthCheck
GetHealthCheck returns the health check which is guaranteed to be a singleton.
func (*HealthCheck) SetBackendsConfiguration ¶
func (hc *HealthCheck) SetBackendsConfiguration(parentCtx context.Context, backends map[string]*BackendConfig)
SetBackendsConfiguration set backends configuration.
type LbStatusUpdater ¶
type LbStatusUpdater struct { BalancerHandler // contains filtered or unexported fields }
LbStatusUpdater wraps a BalancerHandler and a ServiceInfo, so it can keep track of the status of a server in the ServiceInfo.
func NewLBStatusUpdater ¶
func NewLBStatusUpdater(bh BalancerHandler, info *runtime.ServiceInfo, hc *dynamic.ServerHealthCheck) *LbStatusUpdater
NewLBStatusUpdater returns a new LbStatusUpdater.
func (*LbStatusUpdater) RegisterStatusUpdater ¶ added in v2.5.0
func (lb *LbStatusUpdater) RegisterStatusUpdater(fn func(up bool)) error
RegisterStatusUpdater adds fn to the list of hooks that are run when the status of the Balancer changes. Not thread safe.
func (*LbStatusUpdater) RemoveServer ¶
func (lb *LbStatusUpdater) RemoveServer(u *url.URL) error
RemoveServer removes the given server from the BalancerHandler, and updates the status of the server to "DOWN".
func (*LbStatusUpdater) UpsertServer ¶
func (lb *LbStatusUpdater) UpsertServer(u *url.URL, options ...roundrobin.ServerOption) error
UpsertServer adds the given server to the BalancerHandler, and updates the status of the server to "UP".
type Options ¶
type Options struct { Headers map[string]string Hostname string Scheme string Path string Port int FollowRedirects bool Transport http.RoundTripper Interval time.Duration Timeout time.Duration LB Balancer }
Options are the public health check options.
type StatusUpdater ¶ added in v2.5.0
StatusUpdater should be implemented by a service that, when its status changes (e.g. all if its children are down), needs to propagate upwards (to their parent(s)) that change.