public static async Task <EtcdKeyValueStore> TryConnectAsync(
            string connectionString = "http://localhost:2379",
            string caCert           = "")
        {
            _logger.LogDebug("Trying to connect to distributed key-value store at {conn}...",
                             connectionString);

            int        defaultPort = 2379;
            EtcdClient etcdClient  = new EtcdClient(connectionString, defaultPort, caCert);

            var etcdStore = new EtcdKeyValueStore(etcdClient);

            // Warm up:
            bool connected = await etcdStore.ConnectAsync();

            return(connected ? etcdStore : null);
        }
        public static async Task <EtcdKeyValueStore> TryConnectAsync(
            AgentConfiguration agentConfiguration)
        {
            List <int> ports = agentConfiguration.Ports ?? new List <int>(0);

            foreach (int port in ports)
            {
                EtcdKeyValueStore keyValueStore = await TryConnectAsync(
                    agentConfiguration.HostName, port, agentConfiguration.UseTls);

                if (keyValueStore != null)
                {
                    return(keyValueStore);
                }
            }

            return(null);
        }