public ExecutionContextData(Engine engine, Guid executionId, PipelinePhase pipelinePhase, IServiceProvider services, CancellationToken cancellationToken) { Engine = engine ?? throw new ArgumentNullException(nameof(engine)); ExecutionId = executionId; PipelinePhase = pipelinePhase ?? throw new ArgumentNullException(nameof(pipelinePhase)); Services = services ?? throw new ArgumentNullException(nameof(services)); Outputs = new PipelineOutputs(engine.Documents, pipelinePhase, engine.Pipelines); CancellationToken = cancellationToken; }
public ExecutionContextData( PipelinePhase pipelinePhase, Engine engine, IReadOnlyDictionary <string, PhaseResult[]> phaseResults, IServiceProvider services) { Engine = engine ?? throw new ArgumentNullException(nameof(engine)); PipelinePhase = pipelinePhase ?? throw new ArgumentNullException(nameof(pipelinePhase)); Services = services ?? throw new ArgumentNullException(nameof(services)); Outputs = new PhaseOutputs(phaseResults, pipelinePhase, engine.Pipelines); }
private static string GetLogPrefix(IExecutionContext parent, IModule module, PipelinePhase pipelinePhase) { Stack <string> modules = new Stack <string>(); modules.Push(module.GetType().Name); while (parent != null) { modules.Push(parent.Module.GetType().Name); parent = parent.Parent; } return($"{pipelinePhase.PipelineName}/{pipelinePhase.Phase} » {string.Join(" » ", modules)} » "); }
private HashSet <string> GatherProcessPhaseDependencies(PipelinePhase phase, HashSet <string> transientDependencies = null) { if (transientDependencies == null) { transientDependencies = new HashSet <string>(StringComparer.OrdinalIgnoreCase); } foreach (PipelinePhase dependency in phase.Dependencies.Where(x => x.Phase == Phase.Process)) { transientDependencies.Add(dependency.PipelineName); GatherProcessPhaseDependencies(dependency, transientDependencies); } return(transientDependencies); }
public ExecutionContextData( PipelinePhase pipelinePhase, Engine engine, Guid executionId, IReadOnlyDictionary <string, PhaseResult[]> phaseResults, IServiceProvider services, CancellationToken cancellationToken) { Engine = engine ?? throw new ArgumentNullException(nameof(engine)); ExecutionId = executionId; PipelinePhase = pipelinePhase ?? throw new ArgumentNullException(nameof(pipelinePhase)); Services = services ?? throw new ArgumentNullException(nameof(services)); Outputs = new ProcessPhaseOutputs(phaseResults, pipelinePhase, engine.Pipelines); CancellationToken = cancellationToken; }
public PhaseOutputs(IReadOnlyDictionary <string, PhaseResult[]> phaseResults, PipelinePhase currentPhase, IPipelineCollection pipelines) { _phaseResults = phaseResults ?? throw new ArgumentNullException(nameof(phaseResults)); _currentPhase = currentPhase ?? throw new ArgumentNullException(nameof(currentPhase)); _pipelines = pipelines ?? throw new ArgumentNullException(nameof(pipelines)); }
public PipelineOutputs(ConcurrentDictionary <string, ImmutableArray <IDocument> > documents, PipelinePhase pipelinePhase, IPipelineCollection pipelines) { _documents = documents; _pipelinePhase = pipelinePhase; _pipelines = pipelines; }
private Task GetPhaseTaskAsync(Guid executionId, Dictionary <PipelinePhase, Task> phaseTasks, PipelinePhase phase, CancellationTokenSource cancellationTokenSource) { if (phase.Dependencies.Length == 0) { // This will immediately queue the input phase while we continue figuring out tasks, but that's okay return(Task.Run(() => phase.ExecuteAsync(this, executionId, cancellationTokenSource), cancellationTokenSource.Token)); } // We have to explicitly wait the execution task in the continuation function // (the continuation task doesn't wait for the tasks it continues) return(Task.Factory.ContinueWhenAll( phase.Dependencies.Select(x => phaseTasks[x]).ToArray(), dependencies => { // Only run the dependent task if all the dependencies successfully completed if (dependencies.All(x => x.IsCompletedSuccessfully)) { Task.WaitAll(new Task[] { phase.ExecuteAsync(this, executionId, cancellationTokenSource) }, cancellationTokenSource.Token); } else { // Otherwise, throw an exception so that this dependency is also skipped by it's dependents string error = $"Skipping pipeline {phase.PipelineName}/{phase.Phase} due to dependency error"; _logger.LogError(error); throw new Exception(error); } }, cancellationTokenSource.Token)); }
private static ILogger CreateLogger(IExecutionContext parent, IModule module, PipelinePhase pipelinePhase, ILoggerFactory loggerFactory) { Stack <string> modules = new Stack <string>(); modules.Push(module.GetType().Name); while (parent != null) { modules.Push(parent.Module.GetType().Name); parent = parent.Parent; } return(loggerFactory?.CreateLogger($"{pipelinePhase.PipelineName}/{pipelinePhase.Phase}: {string.Join('/', modules)}") ?? NullLogger.Instance); }