weightedaggregator

package
v0.0.0-...-552da36 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 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) NeedUpdateStateOnResume

func (wbsa *Aggregator) NeedUpdateStateOnResume()

NeedUpdateStateOnResume sets the UpdateStateOnResume bool to true, letting a picker update be sent once ResumeStateUpdates is called.

func (*Aggregator) PauseStateUpdates

func (wbsa *Aggregator) PauseStateUpdates()

PauseStateUpdates causes UpdateState calls to not propagate to the parent ClientConn. The last state will be remembered and propagated when ResumeStateUpdates is called.

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) ResumeStateUpdates

func (wbsa *Aggregator) ResumeStateUpdates()

ResumeStateUpdates will resume propagating UpdateState calls to the parent, and call UpdateState on the parent if any UpdateState call was suppressed.

func (*Aggregator) Start

func (wbsa *Aggregator) Start()

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

func (*Aggregator) Stop

func (wbsa *Aggregator) Stop()

Stop stops the aggregator. When the aggregator is stopped, 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