Table of Contents

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

dispatcher IStepDispatcher
flowExecutor IFlowExecutor
graphPlanner IFlowGraphPlanner
stepExecutor IStepExecutor
flowStore IFlowStore
runStore IFlowRunStore
outputsRepository IOutputsRepository
contextAccessor IExecutionContextAccessor
flowRepository IFlowRepository
runtimeStores IEnumerable<IFlowRunRuntimeStore>
runControlStores IEnumerable<IFlowRunControlStore>
runControlOptions FlowRunControlOptions
observabilityOptions FlowObservabilityOptions
telemetry FlowOrchestratorTelemetry
logger ILogger<FlowOrchestratorEngine>
eventNotifier IFlowEventNotifier

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

flowId Guid

The flow that owns the run.

runId Guid

The run containing the step to retry.

stepKey string

The key of the step to retry.

ct CancellationToken

Cancellation token.

Returns

ValueTask<object>

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

ctx IExecutionContext
flow IFlowDefinition

The flow definition that owns this step.

step IStepInstance

The step instance with resolved inputs.

ct CancellationToken

Cancellation token.

Returns

ValueTask<object>

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

triggerContext ITriggerContext
ct CancellationToken

Cancellation token.

Returns

ValueTask<object>

An anonymous object with runId (Guid) and duplicate (bool).

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

flowId Guid

The flow to trigger.

triggerKey string

The manifest trigger key (e.g. "schedule").

jobId string

Optional runtime job/message ID to correlate with the run record.

ct CancellationToken

Cancellation token.

Returns

ValueTask<object>