Class RecoveryCoordinator
- Namespace
- WorkflowForge.Extensions.Persistence.Recovery
- Assembly
- WorkflowForge.Extensions.Persistence.Recovery.dll
Default implementation that uses IWorkflowPersistenceProvider to load snapshots and resume via smith. Foundry/workflow factories must reproduce the same operation order used to create the snapshot.
public sealed class RecoveryCoordinator : IRecoveryCoordinator
- Inheritance
-
RecoveryCoordinator
- Implements
- Inherited Members
Constructors
RecoveryCoordinator(IWorkflowPersistenceProvider, IWorkflowForgeLogger, RecoveryMiddlewareOptions?)
Initializes a new instance of RecoveryCoordinator.
public RecoveryCoordinator(IWorkflowPersistenceProvider provider, IWorkflowForgeLogger logger, RecoveryMiddlewareOptions? options = null)
Parameters
providerIWorkflowPersistenceProviderThe persistence provider used to load and save workflow snapshots.
loggerIWorkflowForgeLoggerLogger for resume failures during bulk recovery. Required: ResumeAllAsync(Func<IWorkflowFoundry>, Func<IWorkflow>, IRecoveryCatalog, CancellationToken) continues past a snapshot it cannot resume and the logger is the only record of it.
optionsRecoveryMiddlewareOptionsOptional recovery middleware options; defaults are used when
null.
Methods
ResumeAllAsync(Func<IWorkflowFoundry>, Func<IWorkflow>, IRecoveryCatalog, CancellationToken)
Resumes all pending workflow executions returned by the specified catalog.
public Task<int> ResumeAllAsync(Func<IWorkflowFoundry> foundryFactory, Func<IWorkflow> workflowFactory, IRecoveryCatalog catalog, CancellationToken cancellationToken = default)
Parameters
foundryFactoryFunc<IWorkflowFoundry>Factory that creates a fresh IWorkflowFoundry for each resumed execution.
workflowFactoryFunc<IWorkflow>Factory that creates the IWorkflow to re-execute.
catalogIRecoveryCatalogThe catalog providing pending snapshots.
cancellationTokenCancellationTokenToken to cancel the resume operation.
Returns
ResumeAsync(Func<IWorkflowFoundry>, Func<IWorkflow>, Guid, Guid, CancellationToken)
Resumes a single workflow execution from a persisted snapshot identified by the given keys.
public Task ResumeAsync(Func<IWorkflowFoundry> foundryFactory, Func<IWorkflow> workflowFactory, Guid foundryKey, Guid workflowKey, CancellationToken cancellationToken = default)
Parameters
foundryFactoryFunc<IWorkflowFoundry>Factory that creates a fresh IWorkflowFoundry for the resumed execution.
workflowFactoryFunc<IWorkflow>Factory that creates the IWorkflow to re-execute.
foundryKeyGuidThe persisted foundry execution identifier.
workflowKeyGuidThe persisted workflow identifier.
cancellationTokenCancellationTokenToken to cancel the resume operation.
Returns
Remarks
IMPORTANT: resume replays the workflow from operation index 0 — the foundry always runs
its full operation list. Completed operations are skipped ONLY by a
PersistenceMiddleware (from WorkflowForge.Extensions.Persistence) attached to the
foundry, which reloads the snapshot and short-circuits operations whose index is below the
snapshot's NextOperationIndex. The foundryFactory MUST attach
that middleware (with the same persistence provider). Without it, every operation — including
ones that already completed and had side effects before the crash — is re-executed, which
can cause duplicate side effects (e.g. double-charging a payment).