grpc: Index | Files

package weightedaggregator

import ""

Package weightedaggregator implements state aggregator for weighted_target balancer.

This is a separate package so it can be shared by weighted_target and eds. The eds balancer will be refactored to use weighted_target directly. After that, all functions and structs in this package can be moved to package weightedtarget and unexported.


Package Files


type Aggregator Uses

type Aggregator struct {
    // contains filtered or unexported fields

Aggregator is the weighted balancer state aggregator.

func New Uses

func New(cc balancer.ClientConn, logger *grpclog.PrefixLogger, newWRR func() wrr.WRR) *Aggregator

New creates a new weighted balancer state aggregator.

func (*Aggregator) Add Uses

func (wbsa *Aggregator) Add(id string, weight uint32)

Add adds a sub-balancer state with weight. It adds a place holder, and waits for the real sub-balancer to update state.

func (*Aggregator) BuildAndUpdate Uses

func (wbsa *Aggregator) BuildAndUpdate()

BuildAndUpdate combines the sub-state from each sub-balancer into one state, and update it to parent ClientConn.

func (*Aggregator) Remove Uses

func (wbsa *Aggregator) Remove(id string)

Remove removes the sub-balancer state. Future updates from this sub-balancer, if any, will be ignored.

func (*Aggregator) Start Uses

func (wbsa *Aggregator) Start()

Start starts the aggregator. It can be called after Close to restart the aggretator.

func (*Aggregator) Stop Uses

func (wbsa *Aggregator) Stop()

Stop stops the aggregator. When the aggregator is closed, it won't call parent ClientConn to update balancer state.

func (*Aggregator) UpdateState Uses

func (wbsa *Aggregator) UpdateState(id string, newState balancer.State)

UpdateState is called to report a balancer state change from sub-balancer. It's usually called by the balancer group.

It calls parent ClientConn's UpdateState with the new aggregated state.

func (*Aggregator) UpdateWeight Uses

func (wbsa *Aggregator) UpdateWeight(id string, newWeight uint32)

UpdateWeight updates the weight for the given id. Note that this doesn't trigger an update to the parent ClientConn. The caller should decide when it's necessary, and call BuildAndUpdate.

Package weightedaggregator imports 7 packages (graph) and is imported by 4 packages. Updated 2020-09-08. Refresh now. Tools for package owners.