Table of Contents

Class ForEachStepHandler

Namespace
FlowOrchestrator.Core.Execution
Assembly
FlowOrchestrator.Core.dll

Built-in step handler for the "ForEach" step type. Resolves the iteration source via FlowOrchestrator.Core.Execution.Internal.ForEachSourceResolver, then returns a StepDispatchHint instructing the engine to enqueue each child step.

public sealed class ForEachStepHandler : IStepHandler
Inheritance
ForEachStepHandler
Implements
Inherited Members

Remarks

Concurrency is controlled by ConcurrencyLimit, which this handler enforces by fanning out only the first ConcurrencyLimit iterations. Every later iteration is admitted by FlowOrchestrator.Core.Execution.Internal.LoopAdmission from the DAG continuation, as an earlier one settles — so ConcurrencyLimit = 1 really does run the body one iteration at a time even when it parks on a WaitForSignal or a polling step (issue #181). Child steps receive __loopItem and __loopIndex injected into their inputs.

A loop that fans out returns Running, not Succeeded: the loop step is settled — by FlowOrchestrator.Core.Execution.Internal.LoopBarrier, from the continuation of its last child — only once every iteration reached a terminal status. That is what makes a step declaring RunAfter = { loop: [Succeeded] } run after the loop body instead of racing it. A loop with nothing to run (zero items, or an empty body) still returns Succeeded immediately — there is no barrier to wait on.

Methods

ExecuteAsync(IExecutionContext, IFlowDefinition, IStepInstance)

Executes the step and returns an optional result value. Return a IStepResult (e.g. StepResult or StepResult<T>) to control status, output, and retry delay; return any other value to implicitly succeed.

public ValueTask<object?> ExecuteAsync(IExecutionContext context, IFlowDefinition flow, IStepInstance step)

Parameters

context IExecutionContext

The ambient execution context for this run (RunId, trigger data, etc.).

flow IFlowDefinition

The flow definition currently executing.

step IStepInstance

The step instance with resolved inputs.

Returns

ValueTask<object>

The step output, or a IStepResult to control execution behaviour.