GetIssuesWithConnections() { await InitializeTask.ConfigureAwait(false); var concurrentBag = new List <IssueLinkLight>(); var rawIssues = await _repository.GetAllIssuesInProject(CustomFields).ConfigureAwait(false); Console.WriteLine($"Loaded issues (count): {rawIssues.Count}"); var getLinks = new TransformManyBlock <IssueLight, IssueLinkLight>( async i => await _repository.GetLinks(i), new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = Environment.ProcessorCount * 4 } ); var collect = new ActionBlock <IssueLinkLight>( i => concurrentBag.Add(i), new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 1 } ); var linkOptions = new DataflowLinkOptions { PropagateCompletion = true }; using var l1 = getLinks.LinkTo(collect, linkOptions); if (rawIssues.Any(x => !getLinks.Post(x))) { throw new Exception($"Failure to queue data for processing. Block already has {getLinks.InputCount} items to be processed."); } getLinks.Complete(); await getLinks.Completion; await collect.Completion; Console.WriteLine($"Loaded links: (count): {concurrentBag.Count}"); return(rawIssues, concurrentBag); }
public async Task <IEnumerable <IssueLinkLight> > GetLinks(IssueLight rawIssue) => await _diskCache.Wrap($"{ rawIssue.Key}_links", () => _repository.GetLinks(rawIssue)).ConfigureAwait(false);