Table of Contents

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

provider IWorkflowPersistenceProvider

The persistence provider used to load and save workflow snapshots.

logger IWorkflowForgeLogger

Logger 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.

options RecoveryMiddlewareOptions

Optional 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

foundryFactory Func<IWorkflowFoundry>

Factory that creates a fresh IWorkflowFoundry for each resumed execution.

workflowFactory Func<IWorkflow>

Factory that creates the IWorkflow to re-execute.

catalog IRecoveryCatalog

The catalog providing pending snapshots.

cancellationToken CancellationToken

Token to cancel the resume operation.

Returns

Task<int>

The number of successfully resumed executions.

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

foundryFactory Func<IWorkflowFoundry>

Factory that creates a fresh IWorkflowFoundry for the resumed execution.

workflowFactory Func<IWorkflow>

Factory that creates the IWorkflow to re-execute.

foundryKey Guid

The persisted foundry execution identifier.

workflowKey Guid

The persisted workflow identifier.

cancellationToken CancellationToken

Token to cancel the resume operation.

Returns

Task

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).