FlowPipe 1.0.1
dotnet add package FlowPipe --version 1.0.1
NuGet\Install-Package FlowPipe -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FlowPipe" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FlowPipe" Version="1.0.1" />
<PackageReference Include="FlowPipe" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FlowPipe --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FlowPipe, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FlowPipe@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FlowPipe&version=1.0.1
#tool nuget:?package=FlowPipe&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FlowPipe
A simple and flexible .NET Core library for flow-based message dispatching and handling.
English User Guide
Introduction
FlowPipe provides a structure that simplifies messaging and message handling in .NET Core projects, with support for behavior pipelines. In the sample project, HTTP requests are treated as messages and processed through handlers and behaviors.
Installation & Getting Started
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddFlowPipe(flowPipeConfig =>
{
// Messages and handlers will be discovered in this assembly
// You can specify multiple assemblies
flowPipeConfig.AddAssembly(Assembly.GetExecutingAssembly());
});
var app = builder.Build();
app.Run();
Message Model
public class PingRequest : IMessage<PingResponse>
{
public int No { get; set; }
}
public class PingResponse
{
public int No { get; set; }
}
Handler Model
public class PingRequestHandler : IMessageHandler<PingRequest, PingResponse>
{
public Task<PingResponse> HandleAsync(PingRequest request, CancellationToken ct = default)
{
Console.WriteLine($"Handler triggered {request.No}");
return Task.FromResult(new PingResponse()
{
No = request.No + 1
});
}
}
Behavior Example
public class ExampleBehavior<TIn, TOut> : IMessageBehavior<TIn, TOut> where TIn : IMessage<TOut>
{
public int BehaviorSequence => 2;
public async Task<TOut> HandleAsync(TIn request, MessageHandlerDelegate<TOut> next, CancellationToken ct)
{
if (request is PingRequest pingRequest)
{
Console.WriteLine($"ExampleBehavior {pingRequest.No}");
}
Console.WriteLine($"{typeof(ExampleBehavior<,>).Name} -> [BEFORE] Handling {typeof(TIn).Name}");
var response = await next();
Console.WriteLine($"{typeof(ExampleBehavior<,>).Name} -> [AFTER] Handled {typeof(TOut).Name}");
if (response is PingResponse pingResponse)
{
Console.WriteLine($"ExampleBehavior {pingResponse.No}");
}
return response;
}
}
Dispatcher Usage Example
app.MapPost("/weatherforecast", async (
[FromBody] PingRequest request,
[FromServices] IMessageDispatcher dispatcher) =>
{
var response = await dispatcher.SendAsync(request);
return response;
})
.WithName("Ping Service");
Dispatcher Usage Example 2 (Pipeline Ignoring)
app.MapPost("/weatherforecast", async (
[FromBody] PingRequest request,
[FromServices] IMessageDispatcher dispatcher) =>
{
var response = await dispatcher.SendAsync(request, CancellationToken.None, false);
return response;
})
.WithName("Ping Service");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.