Interface IWorkflowOperation
- Namespace
- WorkflowForge.Abstractions
- Assembly
- WorkflowForge.dll
Represents a single operation within a workflow that can be forged (executed) in the foundry. Operations are the building blocks of workflows, each performing a specific task. In the Workflow Forge metaphor, operations are the tools and processes used to shape raw materials into finished products.
public interface IWorkflowOperation : IDisposable
- Inherited Members
- Extension Methods
Remarks
For most scenarios, inherit from WorkflowOperationBase instead of implementing this interface directly. The base class provides:
- Automatic unique ID generation
- Default no-op RestoreAsync and Dispose implementations
- Lifecycle hooks (OnBeforeExecuteAsync, OnAfterExecuteAsync)
- Separation of orchestration (ForgeAsync) from business logic (ForgeAsyncCore)
Properties
Id
Gets the unique identifier for this operation.
Guid Id { get; }
Property Value
Name
Gets the name of this operation for identification and logging purposes.
string Name { get; }
Property Value
Methods
ForgeAsync(object?, IWorkflowFoundry, CancellationToken)
Forges (executes) the operation's primary logic with explicit input data and returns output data. The orchestrator controls what data flows into and out of each operation.
Task<object?> ForgeAsync(object? inputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
inputDataobjectThe input data for this operation (can be null).
foundryIWorkflowFoundryThe workflow foundry providing execution context and shared services.
cancellationTokenCancellationTokenThe cancellation token for cooperative cancellation.
Returns
Exceptions
- ArgumentNullException
Thrown when foundry is null.
- ObjectDisposedException
Thrown when the operation has been disposed.
RestoreAsync(object?, IWorkflowFoundry, CancellationToken)
Restores (compensates) the operation's effects to undo its changes. Used for rollback scenarios when subsequent operations fail.
Task RestoreAsync(object? outputData, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
outputDataobjectThe data that was produced by this operation during ForgeAsync.
foundryIWorkflowFoundryThe workflow foundry providing execution context and shared services.
cancellationTokenCancellationTokenThe cancellation token for cooperative cancellation.
Returns
- Task
A task representing the asynchronous restoration.
Exceptions
- ArgumentNullException
Thrown when foundry is null.
- ObjectDisposedException
Thrown when the operation has been disposed.