コード例 #1
0
        private async Task <int> CountItemsInDrawerAsync(CosmosCabinetDrawer drawer)
        {
            var asLinq = _repositoryContainer
                         .Cabinet
                         .GetItemLinqQueryable <CosmosDataAvailable>();

            var query =
                from dataAvailable in asLinq
                where dataAvailable.PartitionKey == drawer.Id
                select dataAvailable;

            return(await query.CountAsync().ConfigureAwait(false));
        }
コード例 #2
0
        private async Task <int> FillCabinetDrawerAsync(CosmosCabinetDrawer drawer, IEnumerable <DataAvailableNotification> notifications)
        {
            var count = 0;
            var tasks = notifications.Select(async x =>
            {
                if (await CheckIdempotencyAsync(x).ConfigureAwait(false))
                {
                    return;
                }

                var cosmosDataAvailable = CosmosDataAvailableMapper.Map(x, drawer.Id);
                await _repositoryContainer
                .Cabinet
                .CreateItemAsync(cosmosDataAvailable)
                .ConfigureAwait(false);

                Interlocked.Increment(ref count);
            });

            await Task.WhenAll(tasks).ConfigureAwait(false);

            return(count);
        }
コード例 #3
0
        private async Task <IEnumerable <CosmosDataAvailable> > GetCabinetDrawerContentsAsync(CosmosCabinetDrawer drawer)
        {
            var maximumSequenceNumber = await _sequenceNumberRepository
                                        .GetMaximumSequenceNumberAsync()
                                        .ConfigureAwait(false);

            var asLinq = _repositoryContainer
                         .Cabinet
                         .GetItemLinqQueryable <CosmosDataAvailable>();

            var query =
                from dataAvailableNotification in asLinq
                where
                dataAvailableNotification.PartitionKey == drawer.Id &&
                dataAvailableNotification.SequenceNumber <= maximumSequenceNumber.Value
                orderby dataAvailableNotification.SequenceNumber
                select dataAvailableNotification;

            return(await query
                   .Skip(drawer.Position)
                   .AsCosmosIteratorAsync()
                   .ToListAsync()
                   .ConfigureAwait(false));
        }