Table of Contents

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

middleware IWorkflowMiddleware

The 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

logger IWorkflowForgeLogger

Optional logger for the foundry. If null, uses smith's default logger.

serviceProvider IServiceProvider

Optional 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

workflow IWorkflow

The workflow this foundry will be associated with.

logger IWorkflowForgeLogger

Optional logger for the foundry. If null, uses smith's default logger.

serviceProvider IServiceProvider

Optional 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

data ConcurrentDictionary<string, object>

Initial data for the foundry.

logger IWorkflowForgeLogger

Optional logger for the foundry. If null, uses smith's default logger.

serviceProvider IServiceProvider

Optional 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

workflow IWorkflow

The workflow to forge.

data ConcurrentDictionary<string, object>

The shared data dictionary for workflow execution.

cancellationToken CancellationToken

The 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

workflow IWorkflow

The workflow to forge.

cancellationToken CancellationToken

The 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

workflow IWorkflow

The workflow to forge.

foundry IWorkflowFoundry

The foundry providing the execution context.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the forging operation.