Table of Contents

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
This ensures parallel foundry executions never interfere with each other.

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:

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

bool

Methods

ForgeAsync(CancellationToken)

Executes all operations in the foundry.

Task ForgeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task

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

operations IEnumerable<IWorkflowOperation>

The operations to set.