docs/persistence.md
Since workflows are typically long running processes, they will need to be persisted to storage between steps. There are several persistence providers available as separate Nuget packages.
To implement a custom persistence provider, create a class that implements IPersistenceProvider interface:
public interface IPersistenceProvider : IWorkflowRepository, ISubscriptionRepository, IEventRepository, IScheduledCommandRepository
{
Task PersistErrors(IEnumerable<ExecutionError> errors, CancellationToken cancellationToken = default);
void EnsureStoreExists();
}
The IPersistenceProvider interface combines four repository interfaces:
Handles workflow instance storage and retrieval:
CreateNewWorkflow - Create and store a new workflow instancePersistWorkflow - Update an existing workflow instanceGetWorkflowInstance - Retrieve a specific workflow instanceGetRunnableInstances - Get workflow instances ready for executionManages workflow events:
CreateEvent - Store a new eventGetEvent - Retrieve a specific eventGetRunnableEvents - Get events ready for processingMarkEventProcessed/Unprocessed - Update event statusHandles event subscriptions:
CreateEventSubscription - Create new event subscriptionGetSubscriptions - Query subscriptions for eventsTerminateSubscription - Remove a subscriptionSetSubscriptionToken/ClearSubscriptionToken - Manage subscription lockingFor future command scheduling (optional):
ScheduleCommand - Schedule a command for future executionProcessCommands - Execute scheduled commandsSupportsScheduledCommands - Indicates if provider supports this featureOnce implemented, register your provider:
services.AddWorkflow(options =>
{
options.UsePersistence(sp => new MyCustomPersistenceProvider());
});