示例#1
0
        private async Task WorkAsync(ConcurrentBag <IdAndValue <string[]> > changesBag)
        {
            await Task.Yield();

            var batchPusher = _batchPusherFactory();

            while (changesBag.TryTake(out var changes))
            {
                // Note that the owner list passed in can be empty (e.g. if the last owner was deleted or removed from
                // the package registration).
                var indexActions = await _searchIndexActionBuilder.UpdateAsync(
                    changes.Id,
                    searchFilters => _searchDocumentBuilder.UpdateOwners(changes.Id, searchFilters, changes.Value));

                // If no index actions are returned, this means that there are no listed packages or no
                // packages at all.
                if (indexActions.IsEmpty)
                {
                    continue;
                }

                batchPusher.EnqueueIndexActions(changes.Id, indexActions);

                // Note that this method can throw a storage exception if one of the version lists has been modified
                // during the execution of this job loop.
                await batchPusher.PushFullBatchesAsync();
            }

            await batchPusher.FinishAsync();
        }