Documentation ¶
Index ¶
- type Limit
- type Loadbalancer
- func (l *Loadbalancer) Select(_ context.Context, req *lbpb.SelectRequest) (*lbpb.SelectResponse, error)
- func (l *Loadbalancer) SelectMany(_ context.Context, req *lbpb.SelectManyRequest) (*lbpb.SelectManyResponse, error)
- func (l *Loadbalancer) Update(_ context.Context, status *lbpb.NodeStatus) (*empty.Empty, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limit ¶
Limit for utilization along a specific dimension. Used to compute fullness by mapping raw metrics onto the [min, max] range.
type Loadbalancer ¶
type Loadbalancer struct { lbpb.UnimplementedLoadBalancerServer // contains filtered or unexported fields }
The Loadbalancer collects utilization metrics from nodes and tries to make sensible decisions about where to send incoming requests.
Loadbalancer objects are goroutine-safe but that's only because they're controlled with a giant mutex.
func New ¶
func New(limits []*Limit, targetFullness float64, nodeTimeout time.Duration) *Loadbalancer
New returns a new Loadbalancer with the given utilization limits and target fullness (1 = 100%). Nodes that we haven't seen for at least a nodeTimeout interval are considered dead.
func (*Loadbalancer) Select ¶
func (l *Loadbalancer) Select(_ context.Context, req *lbpb.SelectRequest) (*lbpb.SelectResponse, error)
Select a node among the available ones, preferably with the given tags. Tags should be passed in preference order, as they will be progressively dropped starting from the tail should we not find any available nodes matching the tag set.
The first return boolean value will be set if the node utilization is above 100% along any dimension (the "overload" signal), while the second returned boolean will be true if we had to drop tags, so it can be used as an "overflow" signal.
Implements the lbpb.LoadBalancer RPC service.
func (*Loadbalancer) SelectMany ¶
func (l *Loadbalancer) SelectMany(_ context.Context, req *lbpb.SelectManyRequest) (*lbpb.SelectManyResponse, error)
func (*Loadbalancer) Update ¶
func (l *Loadbalancer) Update(_ context.Context, status *lbpb.NodeStatus) (*empty.Empty, error)
Update our view of the status of a node. Implements the lbpb.LoadBalancer RPC service.