private void UpdateSubchannelState(Subchannel subchannel, SubchannelState state)
        {
            if (_subchannel != subchannel)
            {
                PickFirstBalancerLog.IgnoredSubchannelStateChange(_logger, subchannel.Id);
                return;
            }

            PickFirstBalancerLog.ProcessingSubchannelStateChanged(_logger, subchannel.Id, state.State, state.Status);

            switch (state.State)
            {
            case ConnectivityState.Ready:
                UpdateChannelState(state.State, new PickFirstPicker(_subchannel));
                break;

            case ConnectivityState.Idle:
                _controller.RefreshResolver();

                // Pick first load balancer waits until a request is made before establishing a connection.
                // Return picker that will request a connection on pick.
                UpdateChannelState(state.State, new RequestConnectionPicker(_subchannel));
                break;

            case ConnectivityState.Connecting:
                UpdateChannelState(state.State, EmptyPicker.Instance);
                break;

            case ConnectivityState.TransientFailure:
                UpdateChannelState(state.State, new ErrorPicker(state.Status));
                break;

            case ConnectivityState.Shutdown:
                UpdateChannelState(state.State, EmptyPicker.Instance);
                _subchannel = null;
                break;
            }
        }
Exemple #2
0
 public void RefreshResolver()
 {
     _controller.RefreshResolver();
 }