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

Method aggregatedConnectivityState

balancer/rls/balancer.go:596–624  ·  view source on GitHub ↗

The aggregated connectivity state reported is determined as follows: - If there is at least one child policy in state READY, the connectivity state is READY. - Otherwise, if there is at least one child policy in state CONNECTING, the connectivity state is CONNECTING. - Otherwise, if there is at leas

()

Source from the content-addressed store, hash-verified

594//
595// Caller must hold lb.stateMu.
596func (b *rlsBalancer) aggregatedConnectivityState() connectivity.State {
597 if len(b.childPolicies) == 0 && b.lbCfg.defaultTarget == "" {
598 return connectivity.Idle
599 }
600
601 var readyN, connectingN, idleN int
602 for _, cpw := range b.childPolicies {
603 state := (*balancer.State)(atomic.LoadPointer(&cpw.state))
604 switch state.ConnectivityState {
605 case connectivity.Ready:
606 readyN++
607 case connectivity.Connecting:
608 connectingN++
609 case connectivity.Idle:
610 idleN++
611 }
612 }
613
614 switch {
615 case readyN > 0:
616 return connectivity.Ready
617 case connectingN > 0:
618 return connectivity.Connecting
619 case idleN > 0:
620 return connectivity.Idle
621 default:
622 return connectivity.TransientFailure
623 }
624}
625
626// UpdateState is a implementation of the balancergroup.BalancerStateAggregator
627// interface. The actual state aggregation functionality is handled

Callers 1

sendNewPickerLockedMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected