MCPcopy
hub / github.com/grpc/grpc-go / Add

Method Add

balancer/weightedtarget/weightedaggregator/aggregator.go:111–128  ·  view source on GitHub ↗

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

(id string, weight uint32)

Source from the content-addressed store, hash-verified

109// Add adds a sub-balancer state with weight. It adds a place holder, and waits for
110// the real sub-balancer to update state.
111func (wbsa *Aggregator) Add(id string, weight uint32) {
112 wbsa.mu.Lock()
113 defer wbsa.mu.Unlock()
114 wbsa.idToPickerState[id] = &weightedPickerState{
115 weight: weight,
116 // Start everything in CONNECTING, so if one of the sub-balancers
117 // reports TransientFailure, the RPCs will still wait for the other
118 // sub-balancers.
119 state: balancer.State{
120 ConnectivityState: connectivity.Connecting,
121 Picker: base.NewErrPicker(balancer.ErrNoSubConnAvailable),
122 },
123 stateToAggregate: connectivity.Connecting,
124 }
125 wbsa.csEvltr.RecordTransition(connectivity.Shutdown, connectivity.Connecting)
126
127 wbsa.buildAndUpdateLocked()
128}
129
130// Remove removes the sub-balancer state. Future updates from this sub-balancer,
131// if any, will be ignored.

Callers

nothing calls this directly

Calls 5

buildAndUpdateLockedMethod · 0.95
NewErrPickerFunction · 0.92
RecordTransitionMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected