Class FlowSignalDispatcher
- Namespace
- FlowOrchestrator.Core.Execution
- Assembly
- FlowOrchestrator.Core.dll
Default implementation that delegates persistence to IFlowSignalStore and re-dispatch to IStepDispatcher.
public sealed class FlowSignalDispatcher : IFlowSignalDispatcher
- Inheritance
-
FlowSignalDispatcher
- Implements
- Inherited Members
Remarks
The resume nudge is dispatched immediately (EnqueueStepAsync(IExecutionContext, IFlowDefinition, IStepInstance, CancellationToken)) whenever
the parked step no longer holds an execution claim, and only falls back to a short delayed dispatch
in the narrow window where it still does. This matters because runtimes route delayed work
differently from immediate work: on Hangfire any non-zero delay becomes BackgroundJob.Schedule,
which parks the job in the Scheduled set until the next DelayedJobScheduler tick
(BackgroundJobServerOptions.SchedulePollingInterval, 15 seconds by default). Always delaying
therefore turned a 500 ms intent into up to 15 seconds of observed resume latency.
Constructors
FlowSignalDispatcher(IFlowSignalStore, IFlowRunStore, IFlowRepository, IStepDispatcher, IOutputsRepository, FlowOrchestratorTelemetry?, IEnumerable<IFlowRunRuntimeStore>?, ILogger<FlowSignalDispatcher>?)
Initialises the dispatcher with its dependencies.
public FlowSignalDispatcher(IFlowSignalStore signalStore, IFlowRunStore runStore, IFlowRepository flowRepository, IStepDispatcher dispatcher, IOutputsRepository outputsRepository, FlowOrchestratorTelemetry? telemetry = null, IEnumerable<IFlowRunRuntimeStore>? runtimeStores = null, ILogger<FlowSignalDispatcher>? logger = null)
Parameters
signalStoreIFlowSignalStorePersistence for signal waiters and delivered payloads.
runStoreIFlowRunStoreUsed to resolve the run that owns the addressed waiter.
flowRepositoryIFlowRepositoryUsed to resolve the flow definition backing the run.
dispatcherIStepDispatcherRuntime adapter that carries the resume nudge back to a worker.
outputsRepositoryIOutputsRepositorySupplies trigger data/headers for the rebuilt execution context.
telemetryFlowOrchestratorTelemetryOptional — when omitted, signal-wait metrics are not emitted.
runtimeStoresIEnumerable<IFlowRunRuntimeStore>Registered runtime stores; the first is used, matching how FlowOrchestratorEngine selects its own store. Taking the sequence rather than a single service keeps the two in agreement when a consumer layers a decorator registration on top of the built-in one — a single-service resolution would bind to the LAST registration while the engine binds to the FIRST, and the dispatcher would then read claim state from a different store than the engine claims against.
loggerILogger<FlowSignalDispatcher>Optional — when omitted, lost resume nudges are not reported anywhere.
Methods
DispatchAsync(Guid, string, string, CancellationToken)
Validates the run, persists the payload on the matching waiter, and nudges the engine to re-execute the parked step so it observes the delivered payload.
public ValueTask<SignalDeliveryResult> DispatchAsync(Guid runId, string signalName, string payloadJson, CancellationToken ct = default)
Parameters
runIdGuidThe run whose
WaitForSignalstep should receive the signal.signalNamestringLogical signal name configured on the step's
signalNameinput.payloadJsonstringPre-serialised JSON payload supplied by the caller.
ctCancellationTokenCancellation token.