Documentation ¶
Overview ¶
Package sd defines some interfaces and implementations for service discovery
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoHosts = errors.New("no hosts available")
ErrNoHosts is the error the balancer must return when there are 0 hosts ready
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
Balancer applys a balancing stategy in order to select the backend host to be used
func NewRandomLB ¶
func NewRandomLB(subscriber Subscriber, seed int64) Balancer
NewRandomLB returns a new balancer using a pseudo-random strategy
func NewRoundRobinLB ¶
func NewRoundRobinLB(subscriber Subscriber) Balancer
NewRoundRobinLB returns a new balancer using a round robin strategy
type FixedSubscriber ¶
type FixedSubscriber []string
FixedSubscriber has a constant set of backend hosts and they never get updated
func (FixedSubscriber) Hosts ¶
func (s FixedSubscriber) Hosts() ([]string, error)
Hosts implements the subscriber interface
type Subscriber ¶
Subscriber keeps the set of backend hosts up to date
func FixedSubscriberFactory ¶
func FixedSubscriberFactory(cfg *config.Backend) Subscriber
FixedSubscriberFactory builds a FixedSubscriber with the received config
type SubscriberFactory ¶
type SubscriberFactory func(*config.Backend) Subscriber
SubscriberFactory builds subscribers with the received config