Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
type Balancer interface {
Balance([]*balancerpb.Server) []*balancerpb.Server
}
Balancer algorithm interface
func NewLeastBusyBalancer ¶
func NewLeastBusyBalancer() Balancer
NewLeastBusyBalancer returns a balancer which returns all known servers in priority order, from least to most busy
func NewRandomBalancer ¶
func NewRandomBalancer() Balancer
NewRandomBalancer returns a balancer which returns all known servers in random order
type BalancerFunc ¶
type BalancerFunc func([]*balancerpb.Server) []*balancerpb.Server
BalancerFunc is a simple balancer function which implements the Balancer interface
func (BalancerFunc) Balance ¶
func (f BalancerFunc) Balance(s []*balancerpb.Server) []*balancerpb.Server
Balance implements Balance
type Config ¶
type Config struct { // Balancer chooses can decide whether to provide a complete list, // a subset, or a specific list of "picked" servers in a particular order. // Default: LeastBusyBalancer Balancer Balancer Discovery struct { // Interval between service discovery checks // Default: 5s Interval time.Duration } LoadReport struct { // Interval between service load pings // Default: 5s Interval time.Duration // MaxFailures allows up to this number of failures for backend // before removing it from set of backends for service. // Negative or zero value ignores failures completely. // Default: 3 MaxFailures int } }
Config options
type Discovery ¶
type Discovery interface { // Resolve accepts a target string and returns a list of addresses Resolve(target string) ([]string, error) }
Discovery describes a service discovery interface
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a gRPC server
func (*Server) GetServers ¶
func (b *Server) GetServers(target string) ([]*balancerpb.Server, error)
GetServers retrieves all known servers for a target service
func (*Server) Servers ¶
func (b *Server) Servers(ctx context.Context, req *balancerpb.ServersRequest) (*balancerpb.ServersResponse, error)
Servers implements RPC server
Click to show internal directories.
Click to hide internal directories.