public async Task UpdateClientRecord(string clientUuid, TimeSpan cleanupWindow, int numAtrs, IReadOnlyList <string> expiredClientIds)
        {
            var prefix = ClientRecordEntry.PathForEntry(clientUuid);
            var opts   = new MutateInOptions().Timeout(_keyValueTimeout).Serializer(DefaultSerializer);
            var specs  = new List <MutateInSpec>
            {
                MutateInSpec.Upsert(ClientRecordEntry.PathForHeartbeat(clientUuid), MutationMacro.Cas, createPath: true),
                MutateInSpec.Upsert(ClientRecordEntry.PathForExpires(clientUuid), (int)cleanupWindow.TotalMilliseconds + ExpiresSafetyMarginMillis, isXattr: true),
                MutateInSpec.Upsert(ClientRecordEntry.PathForNumAtrs(clientUuid), numAtrs, isXattr: true),
                MutateInSpec.SetDoc(new byte?[] { null }), // ExtBinaryMetadata
            };

            var remainingSpecLimit = 16 - specs.Count;

            foreach (var clientId in expiredClientIds.Take(remainingSpecLimit))
            {
                var spec = MutateInSpec.Remove($"{ClientRecordsIndex.FIELD_CLIENTS_FULL}.{clientId}", isXattr: true);
                specs.Add(spec);
            }

            try
            {
                var mutateInReuslt = await Collection.MutateInAsync(ClientRecordsIndex.CLIENT_RECORD_DOC_ID, specs, opts).CAF();
            }
            catch (Core.Exceptions.KeyValue.XattrException ex)
            {
                throw;
            }
        }
示例#2
0
        public async Task RemoveClient(string clientUuid, DurabilityLevel durability = DurabilityLevel.None)
        {
            var opts  = new MutateInOptions().Timeout(RemoveClientTimeout).Durability(DurabilityLevel.None);
            var specs = new MutateInSpec[]
            {
                MutateInSpec.Remove(ClientRecordEntry.PathForEntry(clientUuid), isXattr: true),
            };

            _ = await Collection.MutateInAsync(ClientRecordsIndex.CLIENT_RECORD_DOC_ID, specs, opts).CAF();
        }