Interface IFlowSignalStore
- Namespace
- FlowOrchestrator.Core.Storage
- Assembly
- FlowOrchestrator.Core.dll
Persistence contract for WaitForSignal step waiters: parked steps that resume only when an
external signal is delivered via the dashboard signal endpoint or programmatic call.
public interface IFlowSignalStore
Remarks
Backends must guarantee atomic delivery semantics: a single signal is either persisted exactly once
on the matching live waiter row, or rejected as AlreadyDelivered,
Expired or NotFound. The
in-memory backend uses TryUpdate(TKey, TValue, TValue);
SQL backends use a conditional UPDATE … WHERE DeliveredAt IS NULL AND (ExpiresAt IS NULL OR ExpiresAt > now)
with row-count detection.
Methods
DeliverSignalAsync(Guid, string, string, CancellationToken)
Atomically attempts to deliver a payload to the waiter matching (runId, signalName).
ValueTask<SignalDeliveryResult> DeliverSignalAsync(Guid runId, string signalName, string payloadJson, CancellationToken ct = default)
Parameters
runIdGuidThe run whose waiter should receive the payload.
signalNamestringSignal name to look up.
payloadJsonstringPre-serialised JSON payload supplied by the caller.
ctCancellationTokenCancellation token.
Returns
- ValueTask<SignalDeliveryResult>
Delivered with the resolved
StepKeyon success; NotFound when no waiter matches; Expired when every undelivered matching waiter is past its ExpiresAt; AlreadyDelivered when every matching waiter already holds a payload.
Remarks
The payload goes to the oldest (CreatedAt) waiter that is both
undelivered and live — ExpiresAt is null or later
than the store's current time. An expired waiter never receives a payload and never blocks a live waiter
that shares its signal name. Expiry is judged by the store's clock in the same atomic write that
records the delivery (SYSDATETIMEOFFSET() on SQL Server, now() on PostgreSQL, the injected
TimeProvider in memory), with the same inclusive boundary the WaitForSignal handler
uses (now >= ExpiresAt is expired), so a recorded DeliveredAt is
always earlier than the deadline.
Before 2.0 the stores ignored ExpiresAt: a signal landing between the deadline and the step's safety-net invocation (deadline + 1 s, later under load) was recorded and resumed the step past its timeout. Custom stores must apply the same rule.
GetWaiterAsync(Guid, string, CancellationToken)
Returns the waiter for the given run + step key, or null if none is registered.
ValueTask<FlowSignalWaiter?> GetWaiterAsync(Guid runId, string stepKey, CancellationToken ct = default)
Parameters
runIdGuidstepKeystringctCancellationToken
Returns
RegisterWaiterAsync(Guid, string, string, DateTimeOffset?, CancellationToken)
Registers a new waiter for runId + stepKey. Idempotent —
a duplicate register on the same key updates the signal name / expiry without resetting CreatedAt.
ValueTask RegisterWaiterAsync(Guid runId, string stepKey, string signalName, DateTimeOffset? expiresAt, CancellationToken ct = default)
Parameters
runIdGuidThe run that owns the parked step.
stepKeystringThe step key as authored in the flow manifest.
signalNamestringLogical signal name to address the waiter from the signal endpoint.
expiresAtDateTimeOffset?Optional absolute deadline; null waits indefinitely.
ctCancellationTokenCancellation token.
Returns
RemoveWaiterAsync(Guid, string, CancellationToken)
Removes the waiter row. Called by the handler when the wait is over (delivered, expired, or cancelled).
ValueTask RemoveWaiterAsync(Guid runId, string stepKey, CancellationToken ct = default)
Parameters
runIdGuidstepKeystringctCancellationToken