Class FlowOrchestratorEngine
- Namespace
- FlowOrchestrator.Core.Execution
- Assembly
- FlowOrchestrator.Core.dll
DAG-continuation partial of FlowOrchestratorEngine: legacy sequential next-step resolution, full-graph evaluation with When-skip propagation, and the terminal-status decision via FlowOrchestrator.Core.Execution.Internal.RunTerminationClassifier.
public sealed class FlowOrchestratorEngine : IFlowOrchestrator
- Inheritance
-
FlowOrchestratorEngine
- Implements
- Inherited Members
Remarks
Supports two continuation modes:
- Graph mode (default when IFlowRunRuntimeStore is registered): evaluates the full DAG after each step, enabling parallel fan-out, loop steps, and skip propagation.
- Legacy sequential mode: simple linear next-step resolution when no runtime store is available.
The implementation is split across five partial files for readability — each handles
one responsibility phase: ctor + helpers (this file), trigger lifecycle
(FlowOrchestratorEngine.Trigger.cs), per-step execution
(FlowOrchestratorEngine.Step.cs), DAG continuation
(FlowOrchestratorEngine.Continuation.cs), and dispatch / control / event plumbing
(FlowOrchestratorEngine.Control.cs).
Constructors
FlowOrchestratorEngine(IStepDispatcher, IFlowExecutor, IFlowGraphPlanner, IStepExecutor, IFlowStore, IFlowRunStore, IOutputsRepository, IExecutionContextAccessor, IFlowRepository, IEnumerable<IFlowRunRuntimeStore>, IEnumerable<IFlowRunControlStore>, FlowRunControlOptions, FlowObservabilityOptions, FlowOrchestratorTelemetry, ILogger<FlowOrchestratorEngine>, IFlowEventNotifier?)
Initialises the engine with all required and optional dependencies.
public FlowOrchestratorEngine(IStepDispatcher dispatcher, IFlowExecutor flowExecutor, IFlowGraphPlanner graphPlanner, IStepExecutor stepExecutor, IFlowStore flowStore, IFlowRunStore runStore, IOutputsRepository outputsRepository, IExecutionContextAccessor contextAccessor, IFlowRepository flowRepository, IEnumerable<IFlowRunRuntimeStore> runtimeStores, IEnumerable<IFlowRunControlStore> runControlStores, FlowRunControlOptions runControlOptions, FlowObservabilityOptions observabilityOptions, FlowOrchestratorTelemetry telemetry, ILogger<FlowOrchestratorEngine> logger, IFlowEventNotifier? eventNotifier = null)
Parameters
dispatcherIStepDispatcherflowExecutorIFlowExecutorgraphPlannerIFlowGraphPlannerstepExecutorIStepExecutorflowStoreIFlowStorerunStoreIFlowRunStoreoutputsRepositoryIOutputsRepositorycontextAccessorIExecutionContextAccessorflowRepositoryIFlowRepositoryruntimeStoresIEnumerable<IFlowRunRuntimeStore>runControlStoresIEnumerable<IFlowRunControlStore>runControlOptionsFlowRunControlOptionsobservabilityOptionsFlowObservabilityOptionstelemetryFlowOrchestratorTelemetryloggerILogger<FlowOrchestratorEngine>eventNotifierIFlowEventNotifier
Remarks
eventNotifier is optional with a default of null so
existing positional callers (notably unit tests built before the realtime layer landed)
continue to compile unchanged. When null, Instance
is substituted and lifecycle events are silently discarded.
Methods
RetryStepAsync(Guid, Guid, string, CancellationToken)
Resets a step's state and re-executes it from scratch. Used by the dashboard Retry button.
public ValueTask<object?> RetryStepAsync(Guid flowId, Guid runId, string stepKey, CancellationToken ct = default)
Parameters
flowIdGuidThe flow that owns the run.
runIdGuidThe run containing the step to retry.
stepKeystringThe key of the step to retry.
ctCancellationTokenCancellation token.
Returns
RunStepAsync(IExecutionContext, IFlowDefinition, IStepInstance, CancellationToken)
Executes one step: runs the handler, persists the result, and dispatches the next ready steps. Called by the runtime adapter when a dispatched step job fires.
public ValueTask<object?> RunStepAsync(IExecutionContext ctx, IFlowDefinition flow, IStepInstance step, CancellationToken ct = default)
Parameters
ctxIExecutionContextflowIFlowDefinitionThe flow definition that owns this step.
stepIStepInstanceThe step instance with resolved inputs.
ctCancellationTokenCancellation token.
Returns
TriggerAsync(ITriggerContext, CancellationToken)
Starts a new flow run: persists trigger data, registers idempotency key if present, creates the run record, and dispatches entry steps.
public ValueTask<object?> TriggerAsync(ITriggerContext triggerContext, CancellationToken ct = default)
Parameters
triggerContextITriggerContextctCancellationTokenCancellation token.
Returns
TriggerByScheduleAsync(Guid, string, string?, CancellationToken)
Resolves the flow by flowId and starts a run via its cron trigger.
Used by recurring job runtimes (Hangfire recurring jobs, cron daemon, etc.).
public ValueTask<object?> TriggerByScheduleAsync(Guid flowId, string triggerKey, string? jobId = null, CancellationToken ct = default)
Parameters
flowIdGuidThe flow to trigger.
triggerKeystringThe manifest trigger key (e.g.
"schedule").jobIdstringOptional runtime job/message ID to correlate with the run record.
ctCancellationTokenCancellation token.