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

Method updateSubConnState

interop/orcalb.go:134–164  ·  view source on GitHub ↗
(sc balancer.SubConn, state balancer.SubConnState)

Source from the content-addressed store, hash-verified

132}
133
134func (b *orcab) updateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {
135 b.mu.Lock()
136 if b.stopOOBListeners == nil {
137 b.mu.Unlock()
138 return
139 }
140
141 if state.ConnectivityState == connectivity.Ready {
142 oldStop := b.stopOOBListeners[sc]
143 if oldStop != nil {
144 oldStop()
145 }
146 stop := orca.RegisterOOBListener(sc, &orcaOOBListener{subConn: sc, balancer: b}, orca.OOBListenerOptions{ReportInterval: time.Second})
147 b.stopOOBListeners[sc] = stop
148 b.mu.Unlock()
149 return
150 }
151
152 stop := b.stopOOBListeners[sc]
153 if stop != nil {
154 delete(b.stopOOBListeners, sc)
155 defer func() { stop() }()
156 }
157 b.mu.Unlock()
158
159 if state.ConnectivityState == connectivity.Shutdown {
160 b.oobState.mu.Lock()
161 delete(b.oobState.reports, sc)
162 b.oobState.mu.Unlock()
163 }
164}
165
166// UpdateState intercepts state updates from endpointsharding to wrap the
167// picker with ORCA load report handling.

Callers 1

NewSubConnMethod · 0.95

Calls 3

RegisterOOBListenerFunction · 0.92
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected