internal static KVPair ToKVPair(ConsulSiloRegistration siloRegistration)
        {
            var ret = new KVPair(ConsulSiloRegistrationAssembler.ParseDeploymentSiloKey(siloRegistration.DeploymentId, siloRegistration.Address));

            ret.ModifyIndex = siloRegistration.LastIndex;
            ret.Value       = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(siloRegistration));
            return(ret);
        }
        private async Task <ConsulSiloRegistration> GetConsulSiloRegistration(SiloAddress siloAddress)
        {
            var siloKey     = ConsulSiloRegistrationAssembler.ParseDeploymentSiloKey(_deploymentId, siloAddress);
            var siloKVEntry = await _consulClient.KV.List(siloKey);

            if (siloKVEntry.Response == null)
            {
                return(null);
            }

            var siloKV     = siloKVEntry.Response.Single(KV => KV.Key.Equals(siloKey, StringComparison.OrdinalIgnoreCase));
            var iAmAliveKV = siloKVEntry.Response.SingleOrDefault(KV => KV.Key.Equals(ConsulSiloRegistrationAssembler.ParseSiloIAmAliveKey(siloKey), StringComparison.OrdinalIgnoreCase));

            var siloRegistration = ConsulSiloRegistrationAssembler.FromKVPairs(_deploymentId, siloKV, iAmAliveKV);

            return(siloRegistration);
        }