Documentation ¶
Index ¶
Constants ¶
const RandomPort = 0
Variables ¶
Functions ¶
func ResetLoadBalancer ¶
ResetLoadBalancer will delete the local state file for the load balancer on disk
func SetHTTPProxy ¶
SetHTTPProxy configures a proxy-enabled dialer to be used for all loadbalancer connections, if the agent has been configured to allow use of a HTTP proxy, and the environment has been configured to indicate use of a HTTP proxy for the server URL.
Types ¶
type LoadBalancer ¶
type LoadBalancer struct { ServerURL string ServerAddresses []string Listener net.Listener // contains filtered or unexported fields }
LoadBalancer holds data for a local listener which forwards connections to a pool of remote servers. It is not a proper load-balancer in that it does not actually balance connections, but instead fails over to a new server only when a connection attempt to the currently selected server fails.
func New ¶
func New(ctx context.Context, dataDir, serviceName, serverURL string, lbServerPort int, isIPv6 bool) (_lb *LoadBalancer, _err error)
New contstructs a new LoadBalancer instance. The default server URL, and currently active servers, are stored in a file within the dataDir.
func (*LoadBalancer) LoadBalancerServerURL ¶
func (lb *LoadBalancer) LoadBalancerServerURL() string
func (*LoadBalancer) SetDefault ¶
func (lb *LoadBalancer) SetDefault(serverAddress string)
SetDefault sets the selected address as the default / fallback address
func (*LoadBalancer) SetHealthCheck ¶
func (lb *LoadBalancer) SetHealthCheck(address string, healthCheck func() bool)
SetHealthCheck adds a health-check callback to an address, replacing the default no-op function.
func (*LoadBalancer) Update ¶
func (lb *LoadBalancer) Update(serverAddresses []string)