public async Task <bool> ConnectAsync()
        {
            if (_state == GrpcConnectionState.Ready)
            {
                return(true);
            }
            _state = GrpcConnectionState.Connecting;
            try
            {
                // default timeout = 5s
                var deadLine = DateTime.UtcNow.AddSeconds(5);
                await _internalChannel.ConnectAsync(deadLine);

                _state = GrpcConnectionState.Ready;
                _logger.Info($"Grpc channel connect success. [Server] = {_internalChannel.Target}");
            }
            catch (TaskCanceledException ex)
            {
                _state = GrpcConnectionState.Failure;
                _logger.Warning($"Grpc channel connect timeout. {ex.Message}");
            }
            catch (Exception ex)
            {
                _state = GrpcConnectionState.Failure;
                _logger.Warning($"Grpc channel connect fail. {ex.Message}");
            }

            return(_state == GrpcConnectionState.Ready);
        }
        public void Failure()
        {
            var currentState = _state;

            if (GrpcConnectionState.Ready == currentState)
            {
                _logger.Debug($"Grpc channel state changed. {_state} -> {_internalChannel.State}");
            }

            _state = GrpcConnectionState.Failure;
        }
 public async Task ShutdowmAsync()
 {
     try
     {
         await _internalChannel.ShutdownAsync();
     }
     catch (Exception e)
     {
         _logger.Warning($"Grpc channel shutdown fail. {e.Message}");
     }
     finally
     {
         _state = GrpcConnectionState.Shutdown;
     }
 }