Esempio n. 1
0
 /// <summary>
 /// Pings etcd server for connection check
 /// </summary>
 /// <returns><c>true</c>, if health check was successfull, <c>false</c> otherwise</returns>
 public bool HealthCheck()
 {
     try
     {
         Maintenance.MaintenanceClient maintenanceClient = new Maintenance.MaintenanceClient(_channel);
         var res = maintenanceClient.Status(new StatusRequest(), _headers);
         if (String.IsNullOrWhiteSpace(res.Version))
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Esempio n. 2
0
        private void Init()
        {
            try
            {
                if (_publicRootCa)
                {
                    _channel = new Channel(_host, _port, new SslCredentials());
                }
                else if (_clientSSL)
                {
                    _channel = new Channel(
                        _host,
                        _port,
                        new SslCredentials(
                            _caCert,
                            new KeyCertificatePair(_clientCert, _clientKey)
                            )
                        );
                }
                else if (_ssl)
                {
                    _channel = new Channel(_host, _port, new SslCredentials(_caCert));
                }
                else
                {
                    _channel = new Channel(_host, _port, ChannelCredentials.Insecure);
                }

                if (_basicAuth)
                {
                    Authenticate();
                }

                _kvClient          = new KV.KVClient(_channel);
                _watchClient       = new Watch.WatchClient(_channel);
                _leaseClient       = new Lease.LeaseClient(_channel);
                _lockClient        = new Lock.LockClient(_channel);
                _clusterClient     = new Cluster.ClusterClient(_channel);
                _maintenanceClient = new Maintenance.MaintenanceClient(_channel);
            }
            catch
            {
                throw;
            }
            _disposed = false;
        }