Documentation ¶
Overview ¶
Package lb deals with client-side load balancing across multiple identical instances of services and endpoints. When combined with a service discovery system of record, it enables a more decentralized architecture, removing the need for separate load balancers like HAProxy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoEndpoints = errors.New("no endpoints available")
ErrNoEndpoints is returned when no qualifying endpoints are available.
Functions ¶
func Retry ¶
Retry wraps a service load balancer and returns an endpoint oriented load balancer for the specified service method. Requests to the endpoint will be automatically load balanced via the load balancer. Requests that return errors will be retried until they succeed, up to max times, or until the timeout is elapsed, whichever comes first.
Types ¶
type Balancer ¶
Balancer yields endpoints according to some heuristic.
func NewRandom ¶
func NewRandom(s sd.Subscriber, seed int64) Balancer
NewRandom returns a load balancer that selects services randomly.
func NewRoundRobin ¶
func NewRoundRobin(s sd.Subscriber) Balancer
NewRoundRobin returns a load balancer that returns services in sequence.