weightedaggregator

package
v1.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL