public async Task UpdateIAmAlive(MembershipEntry entry)
        {
            var data = await bucket.GetAsync <CouchBaseSiloRegistration>(entry.SiloAddress.ToParsableString());

            data.Value.IAmAliveTime = entry.IAmAliveTime;
            var address = CouchbaseSiloRegistrationmUtility.ToMembershipEntry(data.Value).Item1.SiloAddress;
            await bucket.UpsertAsync <CouchBaseSiloRegistration>(address.ToParsableString(), data.Value).ConfigureAwait(false);
        }
        public async Task <MembershipTableData> ReadRow(SiloAddress key)
        {
            List <Tuple <MembershipEntry, string> >      entries = new List <Tuple <MembershipEntry, string> >();
            IOperationResult <CouchBaseSiloRegistration> row     = await bucket.GetAsync <CouchBaseSiloRegistration>(key.ToParsableString()).ConfigureAwait(false);

            if (row.Success)
            {
                entries.Add(CouchbaseSiloRegistrationmUtility.ToMembershipEntry(row.Value, row.Cas.ToString()));
            }
            return(new MembershipTableData(entries, new TableVersion(0, "0")));
        }
        public async Task <MembershipTableData> ReadAll()
        {
            BucketContext b            = new BucketContext(bucket);
            var           readAllQuery = new QueryRequest("select meta(membership).id from membership");

            readAllQuery.ScanConsistency(ScanConsistency.RequestPlus);
            readAllQuery.Metrics(false);
            var ids = await bucket.QueryAsync <JObject>(readAllQuery).ConfigureAwait(false);

            var idStrings = ids.Rows.Select(x => x["id"].ToString()).ToArray();
            IDictionary <string, IOperationResult <CouchBaseSiloRegistration> > actuals = await Task.Run
                                                                                              (() => bucket.Get <CouchBaseSiloRegistration>(idStrings));//has no async version with batch reads

            List <Tuple <MembershipEntry, string> > entries = new List <Tuple <MembershipEntry, string> >();

            foreach (var actualRow in actuals.Values)
            {
                //var actualRow = await bucket.GetAsync<CouchBaseSiloRegistration>(r["id"].ToString());
                entries.Add(
                    CouchbaseSiloRegistrationmUtility.ToMembershipEntry(actualRow.Value, actualRow.Cas.ToString()));
            }
            return(new MembershipTableData(entries, new TableVersion(0, "0")));
        }
        public async Task <IList <Uri> > GetGateWays()
        {
            BucketContext b = new BucketContext(ClusterHelper.GetBucket("membership"));
            var           getGateWaysQuery = new QueryRequest("select membership.* from membership");

            getGateWaysQuery.ScanConsistency(ScanConsistency.RequestPlus);
            getGateWaysQuery.Metrics(false);
            IQueryResult <CouchBaseSiloRegistration> result = await bucket.QueryAsync <CouchBaseSiloRegistration>(getGateWaysQuery);

            List <System.Uri> r = result.Rows.Where(x => x.Status == SiloStatus.Active && x.ProxyPort != 0).Select(x => CouchbaseSiloRegistrationmUtility.ToMembershipEntry(x).Item1).Select(x =>
            {
                //EXISTED IN CONSOLE MEMBERSHIP, am not sure why
                //x.SiloAddress.Endpoint.Port = x.ProxyPort;
                return(x.SiloAddress.ToGatewayUri());
            })
                                  .ToList();

            return(r);
        }