Class PollableStepHandler<TInput>
- Namespace
- FlowOrchestrator.Core.Execution
- Assembly
- FlowOrchestrator.Core.dll
Base class for step handlers that need to repeatedly query an external system until a condition is met, using Hangfire's delayed scheduling for pacing.
public abstract class PollableStepHandler<TInput> : IStepHandler<TInput> where TInput : IPollableInput
Type Parameters
TInputStep input type implementing IPollableInput.
- Inheritance
-
PollableStepHandler<TInput>
- Implements
-
IStepHandler<TInput>
- Inherited Members
Remarks
Subclasses implement FetchAsync(IExecutionContext, IFlowDefinition, IStepInstance<TInput>) to perform the actual fetch. The base class manages:
- Tracking poll start time and attempt count in the step inputs (persisted between reschedules).
- Evaluating PollConditionPath against the response.
- Enforcing PollMinAttempts before accepting a positive condition.
- Returning Pending with DelayNextStep to reschedule.
- Returning Failed on timeout.
Methods
ExecuteAsync(IExecutionContext, IFlowDefinition, IStepInstance<TInput>)
Executes the step with strongly-typed inputs and returns an optional result value.
public ValueTask<object?> ExecuteAsync(IExecutionContext ctx, IFlowDefinition flow, IStepInstance<TInput> step)
Parameters
ctxIExecutionContextflowIFlowDefinitionThe flow definition currently executing.
stepIStepInstance<TInput>The step instance with inputs already deserialised to
TInput.
Returns
- ValueTask<object>
The step output, or a IStepResult to control execution behaviour.
FetchAsync(IExecutionContext, IFlowDefinition, IStepInstance<TInput>)
Performs the actual data fetch against the external system.
protected abstract ValueTask<(JsonElement Result, bool IsJson)> FetchAsync(IExecutionContext ctx, IFlowDefinition flow, IStepInstance<TInput> step)
Parameters
ctxIExecutionContextflowIFlowDefinitionstepIStepInstance<TInput>
Returns
- ValueTask<(JsonElement Result, bool IsJson)>
A tuple of the fetched JsonElement payload and a flag indicating whether the response was parsed as valid JSON (required for PollConditionPath evaluation).