Namespace WorkflowForge.Abstractions
Classes
- BaseWorkflowForgeEventArgs
Base class for all WorkflowForge event arguments. Provides common properties shared across workflow and operation events.
- SystemTimeProvider
Default implementation of ISystemTimeProvider that provides real system time. This is the standard implementation used throughout WorkflowForge. Use the singleton Instance property, or inject a custom ISystemTimeProvider for testing.
Interfaces
- ICompensationLifecycleEvents
Compensation (saga pattern) lifecycle events.
- IFoundryServices
Foundry-scoped services and extension-owned objects with explicit lease lifetime. Values are disposed when the foundry lease ends, unlike Properties which holds execution data only.
- IOperationLifecycleEvents
Operation-level lifecycle events.
- ISystemTimeProvider
Provides an abstraction for system time operations to enable testability and time mocking. This is the single source of truth for all time-related operations in WorkflowForge.
- IWorkflow
Represents a complete workflow definition with its operations and metadata.
- IWorkflowExecutionContext
Provides access to the execution context for workflow operations. This interface represents the ambient context pattern, giving operations access to runtime state, properties, logging, and dependency injection services.
- IWorkflowForgeLogger
Interface for logging in WorkflowForge with structured logging support.
- IWorkflowFoundry
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.
- IWorkflowLifecycleEvents
Workflow-level lifecycle events.
- IWorkflowMiddleware
Middleware that executes at the workflow level (wraps entire workflow execution). Workflow middleware executes OUTSIDE the foundry pipeline and can affect the entire workflow.
Execution Order:
Workflow middleware wraps the entire workflow execution, including all operations and operation-level middleware:
WorkflowMiddleware1 (outermost) → WorkflowMiddleware2 → WORKFLOW START → OperationMiddleware1 (per operation) → OperationMiddleware2 → OPERATION EXECUTES → Next operation... ← WORKFLOW END ← WorkflowMiddleware2 ← WorkflowMiddleware1Common Use Cases:
- Workflow Timeouts: Enforce maximum execution time for entire workflow
- Workflow Logging: Log workflow start/completion with consolidated metrics
- Workflow Authorization: Check permissions before allowing workflow execution
- Workflow Caching: Cache workflow results based on inputs
- Workflow Metrics: Collect aggregate metrics across all operations
- IWorkflowMiddlewarePipeline
Provides methods for building the middleware pipeline and operation chain. This interface represents the builder pattern for constructing workflow execution pipelines.
- IWorkflowOperation
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.
- IWorkflowOperationMiddleware
Middleware that executes at the operation level (wraps individual operation execution). Operation middleware executes INSIDE the foundry pipeline for each operation.
Execution Order:
Operation middleware wraps each operation execution in a Russian Doll pattern:
OperationMiddleware1 (outermost - first added) → OperationMiddleware2 → OperationMiddleware3 (innermost - last added) → OPERATION EXECUTES ← OperationMiddleware3 ← OperationMiddleware2 ← OperationMiddleware1Common Use Cases:
- Error Handling: Catch and log operation exceptions
- Timing: Measure operation execution time
- Logging: Log operation start/completion with context
- Validation: Validate operation inputs/outputs
- Retry Logic: Retry failed operations with backoff
- Caching: Cache operation results
- Authorization: Check permissions before executing operation
- IWorkflowOperation<TInput, TOutput>
Strongly-typed workflow operation interface for operations with known input/output types. Provides compile-time type safety for data flow between operations.
- IWorkflowSmith
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).