public async Task RunAsync(CancellationToken cancellationToken = default) { if (!_options.Value.Enqueue) { _logger.LogError("V3 rebuild does not support direct processing at this time, please use --enqueue"); return; } var minCursor = DateTimeOffset.MinValue; var maxCursor = await _cursor.GetAsync(cancellationToken); if (maxCursor == null) { maxCursor = DateTimeOffset.MinValue; } _logger.LogInformation("Finding catalog leafs committed before time {Cursor}...", maxCursor); var catalogClient = _clientFactory.CreateCatalogClient(); var(catalogIndex, catalogLeafItems) = await catalogClient.LoadCatalogAsync( minCursor, maxCursor.Value, _logger, cancellationToken); var messages = catalogLeafItems .Select(l => l.PackageId.ToLowerInvariant()) .Distinct() .Select(ToMessage) .ToList(); await _queue.SendAsync(messages, cancellationToken); }
public async Task ProcessAsync( IEnumerable <CatalogLeafItem> catalogLeafItems, CancellationToken cancellationToken = default) { var messages = catalogLeafItems.Select(ToMessage).ToList(); // Split large message batches and process them in parallel. if (messages.Count > MaxBatchElements) { var messageBatches = SplitMessages(messages); await ParallelAsync.RunAsync( messageBatches, _queue.SendAsync, cancellationToken); } else { await _queue.SendAsync(messages, cancellationToken); } }