grpcgoogle.golang.org/grpc/balancer/weightedtarget/weightedaggregator Index | Files

package weightedaggregator

import "google.golang.org/grpc/balancer/weightedtarget/weightedaggregator"

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.

Index

Types

type Aggregator

type Aggregator struct {
	// contains filtered or unexported fields
}

Aggregator is the weighted balancer state aggregator.

func New

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

New creates a new weighted balancer state aggregator.

func (*Aggregator) Add

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

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

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

func (wbsa *Aggregator) Start()

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

func (*Aggregator) Stop

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

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

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.

Source Files

aggregator.go

Version
v1.47.0-dev
Published
Apr 6, 2022
Platform
linux/amd64
Imports
7 packages
Last checked
58 minutes ago

Tools for package owners.