Documentation
¶
Overview ¶
Package loadbalancer provides simple TCP loadbalancer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TCP ¶
type TCP struct { tcpproxy.Proxy Logger *zap.Logger DialTimeout time.Duration KeepAlivePeriod time.Duration TCPUserTimeout time.Duration // contains filtered or unexported fields }
TCP is a simple loadbalancer for TCP connections across a set of upstreams.
Healthcheck is defined as TCP dial attempt by default.
Zero value of TCP is a valid proxy, use `AddRoute` to install load balancer for address.
Usage: call Run() to start lb and wait for shutdown, call Close() to shutdown lb.
func (*TCP) AddRoute ¶
func (t *TCP) AddRoute(ipPort string, upstreamAddrs iter.Seq[string], options ...upstream.ListOption) error
AddRoute installs load balancer route from listen address ipAddr to list of upstreams.
TCP automatically does background health checks for the upstreams and picks only healthy ones. Healthcheck is simple Dial attempt.
AddRoute should be called before Start().
func (*TCP) IsRouteHealthy ¶
IsRouteHealthy checks if the route has at least one upstream available.