elsa-core/src/core/Elsa.Runtime/Implementations/StimulusInterpreter.cs
Sipke Schoorstra 261c9cb1a5
Implement Default Workflow Invoker (#2979)
* Implement default invoker

* Proto actor improvements

* Refactor workflow registry handling

* Update migrations
2022-04-30 11:10:08 +02:00

20 lines
874 B
C#

using Elsa.Runtime.Services;
namespace Elsa.Runtime.Implementations;
public class StimulusInterpreter : IStimulusInterpreter
{
private readonly IEnumerable<IStimulusHandler> _workflowExecutionInstructionProviders;
public StimulusInterpreter(IEnumerable<IStimulusHandler> workflowExecutionInstructionProviders)
{
_workflowExecutionInstructionProviders = workflowExecutionInstructionProviders;
}
public async Task<IEnumerable<IWorkflowInstruction>> GetExecutionInstructionsAsync(IStimulus stimulus, CancellationToken cancellationToken = default)
{
var providers = _workflowExecutionInstructionProviders.Where(x => x.GetSupportsStimulus(stimulus)).ToList();
var tasks = providers.Select(x => x.GetInstructionsAsync(stimulus, cancellationToken).AsTask());
return (await Task.WhenAll(tasks)).SelectMany(x => x);
}
}