UpdateState pushes the state to the listener, if one is registered.
(state balancer.SubConnState)
| 76 | |
| 77 | // UpdateState pushes the state to the listener, if one is registered. |
| 78 | func (tsc *TestSubConn) UpdateState(state balancer.SubConnState) { |
| 79 | <-tsc.connectCalled.Done() |
| 80 | if tsc.stateListener != nil { |
| 81 | tsc.stateListener(state) |
| 82 | } |
| 83 | // pickfirst registers a health listener synchronously while handing updates |
| 84 | // to READY. It updates the balancing state only after receiving the health |
| 85 | // update. We update the health state here so callers of tsc.UpdateState |
| 86 | // can verify picker updates as soon as UpdateState returns. |
| 87 | if state.ConnectivityState == connectivity.Ready && tsc.healthListener != nil { |
| 88 | tsc.healthListener(balancer.SubConnState{ConnectivityState: connectivity.Ready}) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // Shutdown pushes the SubConn to the ShutdownSubConn channel in the parent |
| 93 | // TestClientConn. |