Interface IWorkflowSmith
- Namespace
- WorkflowForge.Abstractions
- Assembly
- WorkflowForge.dll
Represents a craftsman (smith) that can forge workflows at the foundry. Smiths are the primary executors that coordinate workflow operations and manage the forging process. In the WorkflowForge metaphor, smiths are the skilled artisans who transform raw workflows into finished results.
Supports both simple pattern (smith manages foundry internally) and advanced pattern (reusable foundry).
public interface IWorkflowSmith : IDisposable, IWorkflowLifecycleEvents, ICompensationLifecycleEvents
- Inherited Members
- Extension Methods
Methods
AddWorkflowMiddleware(IWorkflowMiddleware)
Adds workflow-level middleware to the execution pipeline. Workflow middleware executes OUTSIDE the foundry pipeline and wraps the entire workflow execution.
void AddWorkflowMiddleware(IWorkflowMiddleware middleware)
Parameters
middlewareIWorkflowMiddlewareThe workflow middleware to add.
Remarks
Workflow middleware executes in the order they are added (first added = outermost layer). Use workflow middleware for cross-cutting concerns like timeouts, logging, authorization, etc.
Exceptions
- ArgumentNullException
Thrown when middleware is null.
CreateFoundry(IWorkflowForgeLogger?, IServiceProvider?)
Creates a new foundry for general workflow execution. The foundry can be reused across multiple workflow executions.
IWorkflowFoundry CreateFoundry(IWorkflowForgeLogger? logger = null, IServiceProvider? serviceProvider = null)
Parameters
loggerIWorkflowForgeLoggerOptional logger for the foundry. If null, uses smith's default logger.
serviceProviderIServiceProviderOptional service provider for dependency injection.
Returns
- IWorkflowFoundry
A new foundry instance.
CreateFoundryFor(IWorkflow, IWorkflowForgeLogger?, IServiceProvider?)
Creates a new foundry specifically configured for a workflow. This pre-associates the foundry with the workflow but allows for reuse.
IWorkflowFoundry CreateFoundryFor(IWorkflow workflow, IWorkflowForgeLogger? logger = null, IServiceProvider? serviceProvider = null)
Parameters
workflowIWorkflowThe workflow this foundry will be associated with.
loggerIWorkflowForgeLoggerOptional logger for the foundry. If null, uses smith's default logger.
serviceProviderIServiceProviderOptional service provider for dependency injection.
Returns
- IWorkflowFoundry
A new foundry instance configured for the workflow.
CreateFoundryWithData(ConcurrentDictionary<string, object?>, IWorkflowForgeLogger?, IServiceProvider?)
Creates a new foundry with initial data.
IWorkflowFoundry CreateFoundryWithData(ConcurrentDictionary<string, object?> data, IWorkflowForgeLogger? logger = null, IServiceProvider? serviceProvider = null)
Parameters
dataConcurrentDictionary<string, object>Initial data for the foundry.
loggerIWorkflowForgeLoggerOptional logger for the foundry. If null, uses smith's default logger.
serviceProviderIServiceProviderOptional service provider for dependency injection.
Returns
- IWorkflowFoundry
A new foundry instance with the provided data.
ForgeAsync(IWorkflow, ConcurrentDictionary<string, object?>, CancellationToken)
Forges a workflow asynchronously using the provided data dictionary. The smith creates a foundry internally over the supplied dictionary, so workflow results are readable from it after the call returns.
Task ForgeAsync(IWorkflow workflow, ConcurrentDictionary<string, object?> data, CancellationToken cancellationToken = default)
Parameters
workflowIWorkflowThe workflow to forge.
dataConcurrentDictionary<string, object>The shared data dictionary for workflow execution.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the forging operation.
ForgeAsync(IWorkflow, CancellationToken)
Forges a workflow asynchronously with automatic foundry management. This is the recommended simple pattern where the smith creates and manages the foundry internally.
Task ForgeAsync(IWorkflow workflow, CancellationToken cancellationToken = default)
Parameters
workflowIWorkflowThe workflow to forge.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the forging operation.
ForgeAsync(IWorkflow, IWorkflowFoundry, CancellationToken)
Forges a workflow asynchronously using a pre-configured foundry. This is the advanced pattern for scenarios requiring foundry reuse across multiple workflows. The foundry's CurrentWorkflow will be set to the provided workflow during execution. The caller retains ownership of the foundry and of the operations and middleware it holds.
Task ForgeAsync(IWorkflow workflow, IWorkflowFoundry foundry, CancellationToken cancellationToken = default)
Parameters
workflowIWorkflowThe workflow to forge.
foundryIWorkflowFoundryThe foundry providing the execution context.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
A task representing the forging operation.