FlowT 1.3.0
dotnet add package FlowT --version 1.3.0
NuGet\Install-Package FlowT -Version 1.3.0
<PackageReference Include="FlowT" Version="1.3.0" />
<PackageVersion Include="FlowT" Version="1.3.0" />
<PackageReference Include="FlowT" />
paket add FlowT --version 1.3.0
#r "nuget: FlowT, 1.3.0"
#:package FlowT@1.3.0
#addin nuget:?package=FlowT&version=1.3.0
#tool nuget:?package=FlowT&version=1.3.0
FlowT - High-Performance Orchestration Library for .NET
FlowT is a high-performance orchestration library for .NET that implements the Chain of Responsibility pattern with a fluent API. Build maintainable, testable, and ultra-fast pipelines with specifications, policies, and handlers.
๐ Full Documentation: https://github.com/vlasta81/FlowT
๐ฆ Package Information
| Property | Value |
|---|---|
| Package | FlowT |
| NuGet | https://www.nuget.org/packages/FlowT/ |
| Targets | .NET 10.0 (Primary), .NET Standard 2.0 (Compatibility) |
| Dependencies | None (zero external dependencies) |
| Built-in plugins | 10 (AuditPlugin, TenantPlugin, IdempotencyPlugin, PerformancePlugin, FlowScopePlugin, FeatureFlagPlugin, CorrelationPlugin, UserIdentityPlugin, RetryStatePlugin, TransactionPlugin) |
| License | MIT |
โจ Key Features
๐ Performance
- โก 2.7ร faster than DispatchR - The fastest .NET orchestration library
- โก 9ร faster than MediatR - Singleton architecture with cached pipelines
- ๐พ 84% less memory than MediatR - Zero-allocation fast paths
- ๐ฅ Thread-safe - Lock-free operations with compile-time safety
๐ฏ Developer Experience
- ๐งฉ Modular Architecture -
IFlowModulefor clean feature organization - ๐ Chain of Responsibility - Composable pipeline with specs, policies, handlers
- ๐จ Fluent API - Intuitive pipeline configuration
- ๐ Automatic Context - No manual FlowContext creation needed
- ๐ก๏ธ 27 Roslyn Analyzers - Compile-time safety for threading & DI
๐ก Advanced Features
- ๐ FlowInterrupt - Type-safe error handling without exceptions
- ๐งฉ
FlowSpecification<TRequest>- Optional abstract base class:Continue(),Fail(),Stop()helpers (zero-allocation cached path) - ๐ Plugin System - PerFlow services with 8.7ร warm-path speedup, 10 built-in plugins
- ๐ Named Keys - Store multiple values of same type
- ๐ญ Scoped Services - Safe
ctx.Service<T>()in singleton handlers - ๐ท๏ธ Feature Flags -
FeatureFlagPluginwrapsIVariantFeatureManagerwith per-flow cache - ๐ Audit Trail -
AuditPluginaccumulates structured events per flow execution - โฑ๏ธ Performance Metrics -
PerformancePluginmeasures named code sections withStopwatch - ๐ข Multi-tenancy -
TenantPluginresolves tenant from claim โ header โ route โ default - ๐ Idempotency -
IdempotencyPluginreadsX-Idempotency-Keyheader once per flow - ๐ญ DI Scope Control -
FlowScopePluginfor explicit scopes in background/non-HTTP flows
๐ Quick Start
Installation
dotnet add package FlowT
Basic Example
// 1. Define request/response
public record CreateUserRequest(string Email, string Name);
public record CreateUserResponse(Guid Id, string Email);
// 2. Create handler
public class CreateUserHandler : IFlowHandler<CreateUserRequest, CreateUserResponse>
{
public async ValueTask<CreateUserResponse> HandleAsync(
CreateUserRequest request, FlowContext context)
{
var db = context.Service<AppDbContext>();
var user = new User { Email = request.Email, Name = request.Name };
db.Users.Add(user);
await db.SaveChangesAsync(context.CancellationToken);
return new CreateUserResponse(user.Id, user.Email);
}
}
// 3. Define flow with pipeline
[FlowDefinition]
public class CreateUserFlow : FlowDefinition<CreateUserRequest, CreateUserResponse>
{
protected override void Configure(IFlowBuilder<CreateUserRequest, CreateUserResponse> flow)
{
flow
.Check<ValidateEmailSpecification>()
.Use<LoggingPolicy>()
.OnInterrupt(interrupt =>
new CreateUserResponse(Guid.Empty, interrupt.Message))
.Handle<CreateUserHandler>();
}
}
// 4. Register module
[FlowModule]
public class UserModule : IFlowModule
{
public void Register(IServiceCollection services)
{
services.AddFlow<CreateUserFlow, CreateUserRequest, CreateUserResponse>();
}
public void MapEndpoints(IEndpointRouteBuilder app)
{
app.MapPost("/api/users", async (
CreateUserRequest request,
CreateUserFlow flow,
HttpContext httpContext) =>
{
return await flow.ExecuteAsync(request, httpContext);
});
}
}
// 5. In Program.cs
builder.Services.AddFlowModules(typeof(Program).Assembly);
app.MapFlowModules();
๐ Performance
| Metric | Result |
|---|---|
| Speed vs DispatchR | 1.6-2.8ร faster |
| Speed vs MediatR | 9ร faster |
| Memory vs MediatR | 84% less |
๐ Detailed Benchmarks: https://github.com/vlasta81/FlowT/tree/main/benchmarks/FlowT.Benchmarks
๐ Core Concepts
Modules (IFlowModule)
Organize features into cohesive modules with [FlowModule] attribute for auto-discovery.
Flows (FlowDefinition<TRequest, TResponse>)
Define reusable orchestration pipelines with [FlowDefinition] attribute.
Context (FlowContext)
Per-request execution context with scoped service resolution, storage, and events.
Specifications (IFlowSpecification<TRequest> / FlowSpecification<TRequest>)
Reusable validation and business rules that can interrupt flow with FlowInterrupt. Inherit from FlowSpecification<TRequest> for Continue(), Fail(), and Stop() helpers.
Policies (FlowPolicy<TRequest, TResponse>)
Cross-cutting concerns as reusable middleware (logging, caching, transactions).
Plugins (Plugin<T>())
PerFlow services shared across all pipeline stages with automatic caching.
Register with services.AddFlowPlugin<IMyPlugin, MyPlugin>(), resolve with context.Plugin<IMyPlugin>().
Built-in Plugins
| Plugin | Interface | Description |
|---|---|---|
AuditPlugin |
IAuditPlugin |
Accumulates structured AuditEntry records per flow execution |
TenantPlugin |
ITenantPlugin |
Resolves tenant from claim tid โ X-Tenant-Id header โ route โ "default" |
IdempotencyPlugin |
IIdempotencyPlugin |
Reads X-Idempotency-Key header once per flow |
PerformancePlugin |
IPerformancePlugin |
Measures named sections with Stopwatch; results in Elapsed dictionary |
FlowScopePlugin |
IFlowScopePlugin |
Creates an explicit IServiceScope โ useful in non-HTTP/background flows |
FeatureFlagPlugin |
IFeatureFlagPlugin |
Evaluates feature flags via IVariantFeatureManager with per-flow caching |
CorrelationPlugin |
ICorrelationPlugin |
Reads X-Correlation-Id header; falls back to FlowId |
UserIdentityPlugin |
IUserIdentityPlugin |
Exposes ClaimsPrincipal, UserId, Email, IsAuthenticated, IsInRole |
RetryStatePlugin |
IRetryStatePlugin |
Tracks retry attempt counter for retry policies |
TransactionPlugin |
ITransactionPlugin (abstract) |
Base for custom transaction implementations (BeginAsync, CommitAsync, RollbackAsync) |
Example โ FeatureFlagPlugin + AuditPlugin
// appsettings.json
{
"FeatureManagement": {
"NewCheckout": true
}
}
// Program.cs
builder.Services.AddFeatureManagement();
builder.Services.AddFlowPlugin<IFeatureFlagPlugin, FeatureFlagPlugin>();
builder.Services.AddFlowPlugin<IAuditPlugin, AuditPlugin>();
// Handler
public async ValueTask<Response> HandleAsync(Request req, FlowContext ctx)
{
var ff = ctx.Plugin<IFeatureFlagPlugin>();
if (!await ff.IsEnabledAsync("NewCheckout", ctx.CancellationToken))
return new Response { Skipped = true };
var audit = ctx.Plugin<IAuditPlugin>();
audit.Record("CheckoutStarted", new { req.UserId });
// ... business logic ...
audit.Record("CheckoutCompleted", new { req.UserId, OrderId = order.Id });
return new Response { OrderId = order.Id };
}
๐ Complete Guide: https://github.com/vlasta81/FlowT/blob/main/README.md#-core-concepts
๐ก๏ธ Compile-Time Safety
FlowT includes 27 Roslyn analyzers that catch issues at compile-time:
๐ด Errors (Build fails - must fix!)
- FlowT002: Non-thread-safe collections (List, Dictionary, etc.)
- FlowT003: Captive scoped dependencies (DbContext in constructor)
- FlowT004: Static mutable state
- FlowT006: FlowContext stored in field
- FlowT007: Request/Response objects in fields
- FlowT010: Thread.Sleep() in async methods
- FlowT011: Missing .Handle<T>() in FlowDefinition.Configure()
- FlowT012: IServiceProvider stored in field
- FlowT013: CancellationTokenSource stored in field
- FlowT015: Mutable public/internal properties
- FlowT018: Lazy<T> without thread-safety mode
- FlowT019: State leak types (StringBuilder, Stream, Stopwatch, arrays)
- FlowT021: FlowPlugin stored in singleton field
- FlowT022: Multiple .Handle<T>() calls in Configure()
- FlowT026: Thread.Sleep() in synchronous flow methods
โ ๏ธ Warnings
- FlowT001: Mutable instance fields
- FlowT005: Async void methods
- FlowT008: Lock on
thisortypeof(T) - FlowT010: Synchronous blocking (.Result, .Wait())
- FlowT016: Task/ValueTask storage
- FlowT017: Manual Thread creation
- FlowT020: ConfigureAwait(false) loses HttpContext/FlowContext
- FlowT023: new HttpClient() in flow component (socket exhaustion)
- FlowT024: Synchronous file I/O in async flow method
โน๏ธ Info (Suggestions)
- FlowT009: Missing CancellationToken propagation
- FlowT014: Empty catch blocks
- FlowT025: Direct IServiceProvider access (prefer context.Service<T>())
๐ All Analyzer Rules: https://github.com/vlasta81/FlowT/blob/main/src/FlowT.Analyzers/README.md
Example:
// โ FlowT003: Build fails!
public class BadHandler : IFlowHandler<Request, Response>
{
private readonly AppDbContext _db; // Captive dependency!
public BadHandler(AppDbContext db) { _db = db; }
}
// โ
Correct pattern
public class GoodHandler : IFlowHandler<Request, Response>
{
public async ValueTask<Response> HandleAsync(Request req, FlowContext ctx)
{
var db = ctx.Service<AppDbContext>(); // Safe!
return await db.ProcessAsync(req);
}
}
๐ Migration Guides
UserIdentityPlugin Removal (v1.2.0)
The UserIdentityPlugin and IUserIdentityPlugin interface have been removed. User identity functionality is now provided by built-in methods on FlowContext:
| Old Plugin Method | New Built-in Method |
|---|---|
context.Plugin<IUserIdentityPlugin>().UserId |
context.GetUserId() |
context.Plugin<IUserIdentityPlugin>().Email |
context.GetUser()?.Email |
context.Plugin<IUserIdentityPlugin>().IsAuthenticated |
context.IsAuthenticated() |
context.Plugin<IUserIdentityPlugin>().IsInRole("Admin") |
context.IsInRole("Admin") |
context.Plugin<IUserIdentityPlugin>().Principal |
context.GetUser() |
๐ Migration Guide: https://github.com/vlasta81/FlowT/blob/main/docs/MIGRATION_UserIdentityPlugin.md
๐ Documentation
| Resource | Link |
|---|---|
| Full README | https://github.com/vlasta81/FlowT |
| API Reference | https://github.com/vlasta81/FlowT/tree/main/docs/api |
| Best Practices | https://github.com/vlasta81/FlowT/blob/main/docs/BEST_PRACTICES.md |
| FlowContext Guide | https://github.com/vlasta81/FlowT/blob/main/docs/FLOWCONTEXT.md |
| Plugin System | https://github.com/vlasta81/FlowT/blob/main/docs/PLUGINS.md |
| Benchmarks | https://github.com/vlasta81/FlowT/tree/main/benchmarks/FlowT.Benchmarks |
| Sample App | https://github.com/vlasta81/FlowT/tree/main/samples/FlowT.SampleApp |
| Analyzers | https://github.com/vlasta81/FlowT/tree/main/src/FlowT.Analyzers |
๐งช Testing
- 277+ unit tests with full coverage
- xUnit test framework
- Thread-safety and concurrency tests
- Analyzer verification tests
๐ Test Suite: https://github.com/vlasta81/FlowT/tree/main/tests/FlowT.Tests
๐ค Contributing
Found a bug or have a feature request? Please open an issue: https://github.com/vlasta81/FlowT/issues
Deprecation Policy
For future breaking changes, FlowT follows a deprecation-first approach:
- Features are marked
[Obsolete]with migration guidance in a minor version - Deprecated features are removed in the next major version
- Migration guides are provided in
docs/MIGRATION_*.md
๐ License
MIT License - see LICENSE file for details.
Made with โค๏ธ by vlasta81
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.FeatureManagement.AspNetCore (>= 4.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.0 | 86 | 4/23/2026 |
| 1.2.0 | 137 | 3/28/2026 |
| 1.1.2 | 69 | 3/22/2026 |
| 1.1.1-dev.0 | 72 | 3/22/2026 |
| 1.0.0 | 87 | 3/15/2026 |
See CHANGELOG.md for detailed release notes.