Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoEndpoints = errors.New("no endpoints available")
ErrNoEndpoints is returned when a load balancer (or one of its components) has no endpoints to return. In a request lifecycle, this is usually a fatal error.
var ErrPublisherStopped = errors.New("publisher stopped")
ErrPublisherStopped is returned by publishers when the underlying implementation has been terminated and can no longer serve requests.
Functions ¶
func Retry ¶
Retry wraps the load balancer to make it behave like a simple endpoint. 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 Factory ¶
Factory is a function that converts an instance string, e.g. a host:port, to a usable endpoint. Factories are used by load balancers to convert instances returned by Publishers (typically host:port strings) into endpoints. Users are expected to provide their own factory functions that assume specific transports, or can deduce transports by parsing the instance string.
type LoadBalancer ¶
LoadBalancer describes something that can yield endpoints for a remote service method.
type Publisher ¶
Publisher describes something that provides a set of identical endpoints. Different publisher implementations exist for different kinds of service discovery systems.
type Random ¶
type Random struct {
// contains filtered or unexported fields
}
Random is a completely stateless load balancer that chooses a random endpoint to return each time.
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
RoundRobin is a simple load balancer that returns each of the published endpoints in sequence.
func NewRoundRobin ¶
func NewRoundRobin(p Publisher) *RoundRobin
NewRoundRobin returns a new RoundRobin load balancer.