updateState updates the connectivity.State of ClientConn. If there's a change it notifies goroutines waiting on state change to happen.
(state connectivity.State)
| 605 | // If there's a change it notifies goroutines waiting on state change to |
| 606 | // happen. |
| 607 | func (csm *connectivityStateManager) updateState(state connectivity.State) { |
| 608 | csm.mu.Lock() |
| 609 | defer csm.mu.Unlock() |
| 610 | if csm.state == connectivity.Shutdown { |
| 611 | return |
| 612 | } |
| 613 | if csm.state == state { |
| 614 | return |
| 615 | } |
| 616 | csm.state = state |
| 617 | csm.channelz.ChannelMetrics.State.Store(&state) |
| 618 | csm.pubSub.Publish(state) |
| 619 | |
| 620 | channelz.Infof(logger, csm.channelz, "Channel Connectivity change to %v", state) |
| 621 | if csm.notifyChan != nil { |
| 622 | // There are other goroutines waiting on this channel. |
| 623 | close(csm.notifyChan) |
| 624 | csm.notifyChan = nil |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | func (csm *connectivityStateManager) getState() connectivity.State { |
| 629 | csm.mu.Lock() |
no test coverage detected