Interface IWorkflowFoundry
- Namespace
- WorkflowForge.Abstractions
- Assembly
- WorkflowForge.dll
The foundry provides operations with access to workflow properties, logging, and services. It serves as the execution context for workflow operations, maintaining runtime state and services. In the WorkflowForge metaphor, the foundry is where raw materials (data) are shaped into finished products (results).
Execution Context Pattern:
The foundry implements the "Ambient Context" pattern, providing operations with access to:
- Properties: Thread-safe state management (ConcurrentDictionary) isolated per foundry instance
- Logger: Structured logging capabilities for operation diagnostics
- ServiceProvider: Dependency injection for user operations to resolve services
- CurrentWorkflow: Reference to the workflow being executed
Isolation Guarantees:
Each foundry lease is isolated:
- Unique ExecutionId per lease
- Properties visible only to that lease; execution state is cleared between leases
- Independent middleware pipeline
- Isolated event subscriptions
Lifecycle:
Foundries can be reused when you own the instance; the default pooled smith clears execution state after each run. Dispose the foundry (or end the lease) to release Services.
The foundry pipeline is frozen during execution. Operations and middleware cannot be added or removed while ForgeAsync(CancellationToken) is running.
public interface IWorkflowFoundry : IWorkflowExecutionContext, IWorkflowMiddlewarePipeline, IDisposable, IOperationLifecycleEvents
- Inherited Members
- Extension Methods
Remarks
The foundry is the execution environment where operations are performed. It provides thread-safe access to shared properties, logging capabilities, and dependency injection services. Each foundry instance represents an isolated execution context that can host one or more workflow executions.
Interface Segregation:
IWorkflowFoundry composes multiple focused interfaces:
- IWorkflowExecutionContext: Provides access to execution state, properties, and services
- IWorkflowMiddlewarePipeline: Provides methods for building the execution pipeline
- IOperationLifecycleEvents: Provides event subscriptions for operation lifecycle
- IDisposable: Provides synchronous resource cleanup
This composition allows code to depend on only the specific capabilities it needs, following the Interface Segregation Principle (ISP).
Properties
IsFrozen
Gets whether the foundry pipeline is frozen for execution.
bool IsFrozen { get; }
Property Value
Methods
ForgeAsync(CancellationToken)
Executes all operations in the foundry.
Task ForgeAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
ReplaceOperations(IEnumerable<IWorkflowOperation>)
Replaces the current operations with a new sequence. The foundry does not take ownership: disposing it does not dispose the operations.
void ReplaceOperations(IEnumerable<IWorkflowOperation> operations)
Parameters
operationsIEnumerable<IWorkflowOperation>The operations to set.