public ResourceVerifierBlock(CancellationToken cancellationToken, IStatistics statistics, IResourceVerifier resourceVerifier, ILog log) : base(cancellationToken, maxDegreeOfParallelism: 300) { _log = log; _statistics = statistics; _resourceVerifier = resourceVerifier; _cancellationToken = cancellationToken; var generalDataflowBlockOptions = new DataflowBlockOptions { CancellationToken = cancellationToken }; VerificationResults = new BufferBlock <VerificationResult>(generalDataflowBlockOptions); FailedProcessingResults = new BufferBlock <FailedProcessingResult>(generalDataflowBlockOptions); Events = new BufferBlock <Event>(new DataflowBlockOptions { EnsureOrdered = true, CancellationToken = cancellationToken }); base.Completion.ContinueWith(_ => { Events.Complete(); VerificationResults.Complete(); FailedProcessingResults.Complete(); }); }
public void Return(IResourceVerifier resourceVerifier) { if (_objectDisposed) { throw new ObjectDisposedException(nameof(NetworkServicePool)); } _resourceVerifierPool.Add(resourceVerifier); }
public ResourceVerifierBlock(IResourceVerifier resourceVerifier, ILog log) : base(maxDegreeOfParallelism: Configurations.MaxNetworkConnectionCount) { _log = log; _resourceVerifier = resourceVerifier; _cancellationTokenSource = new CancellationTokenSource(); FailedProcessingResults = new BufferBlock <FailedProcessingResult>(); }
public BrokenLinkCollectionWorkflow(CancellationToken cancellationToken, Configurations configurations, IStatistics statistics, IHardwareMonitor hardwareMonitor, IResourceExtractor resourceExtractor, IReportWriter reportWriter, ILog log, IResourceEnricher resourceEnricher, IResourceVerifier resourceVerifier, Func <IHtmlRenderer> getHtmlRenderer) { _log = log; _coordinatorBlock = new CoordinatorBlock(cancellationToken, log); _eventBroadcasterBlock = new EventBroadcasterBlock(cancellationToken); _processingResultGeneratorBlock = new ProcessingResultGeneratorBlock(cancellationToken, resourceExtractor, log); _reportWriterBlock = new ReportWriterBlock(cancellationToken, reportWriter, log); _resourceEnricherBlock = new ResourceEnricherBlock(cancellationToken, resourceEnricher, log); _resourceVerifierBlock = new ResourceVerifierBlock(cancellationToken, statistics, resourceVerifier, log); _htmlRendererBlock = new HtmlRendererBlock( cancellationToken, statistics, log, configurations, hardwareMonitor, getHtmlRenderer ); WireUpBlocks(); void WireUpBlocks() { var generalDataflowLinkOptions = new DataflowLinkOptions { PropagateCompletion = true }; _coordinatorBlock.LinkTo(NullTarget <Resource>(), PropagateNullObjectsOnly <Resource>()); _coordinatorBlock.LinkTo(_resourceEnricherBlock, generalDataflowLinkOptions); _resourceEnricherBlock.LinkTo(NullTarget <Resource>(), PropagateNullObjectsOnly <Resource>()); _resourceEnricherBlock.LinkTo(_resourceVerifierBlock, generalDataflowLinkOptions); _resourceEnricherBlock.FailedProcessingResults.LinkTo(_coordinatorBlock); _resourceVerifierBlock.LinkTo(NullTarget <Resource>(), PropagateNullObjectsOnly <Resource>()); _resourceVerifierBlock.LinkTo(_htmlRendererBlock, generalDataflowLinkOptions); _resourceVerifierBlock.FailedProcessingResults.LinkTo(_coordinatorBlock); _resourceVerifierBlock.VerificationResults.LinkTo(_reportWriterBlock); _resourceVerifierBlock.Events.LinkTo(_eventBroadcasterBlock); _htmlRendererBlock.LinkTo(NullTarget <RenderingResult>(), PropagateNullObjectsOnly <RenderingResult>()); _htmlRendererBlock.LinkTo(_processingResultGeneratorBlock, generalDataflowLinkOptions); _htmlRendererBlock.VerificationResults.LinkTo(_reportWriterBlock, generalDataflowLinkOptions); _htmlRendererBlock.FailedProcessingResults.LinkTo(_coordinatorBlock); _htmlRendererBlock.Events.LinkTo(_eventBroadcasterBlock, generalDataflowLinkOptions); _processingResultGeneratorBlock.LinkTo(NullTarget <ProcessingResult>(), PropagateNullObjectsOnly <ProcessingResult>()); _processingResultGeneratorBlock.LinkTo(_coordinatorBlock); _eventBroadcasterBlock.LinkTo(NullTarget <Event>(), PropagateNullObjectsOnly <Event>()); Predicate <T> PropagateNullObjectsOnly <T>() { return(@object => @object == null); } ITargetBlock <T> NullTarget <T>() { return(DataflowBlock.NullTarget <T>()); } } }