Flux.Mediator 2.2.0

dotnet add package Flux.Mediator --version 2.2.0
                    
NuGet\Install-Package Flux.Mediator -Version 2.2.0
                    
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="Flux.Mediator" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Flux.Mediator" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Flux.Mediator" />
                    
Project file
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 Flux.Mediator --version 2.2.0
                    
#r "nuget: Flux.Mediator, 2.2.0"
                    
#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 Flux.Mediator@2.2.0
                    
#: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=Flux.Mediator&version=2.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Flux.Mediator&version=2.2.0
                    
Install as a Cake Tool

Flux.Mediator

Flux.Mediator is a lightweight, high‑performance mediator library for .NET focused on clean architecture, explicit contracts, and zero magic.

It provides in‑process request/response dispatching with strong typing, DI integration --- designed to be predictable, testable, and framework‑agnostic.


Features

  • Request / Response model
  • Notification model
  • Strongly typed handlers
  • Thread-safe & stateless mediator
  • Clean separation of Abstractions and Core
  • Designed for testability

Packages


Packages Description
Flux.Mediator.Abstractions Contracts (IRequest, IMediator, Handlers)
Flux.Mediator.Core Mediator implementation
Flux.Mediator.Extensions.DependencyInjection Developer Experience (DX)

Installation

dotnet add package Flux.Mediator

Basic Concepts

Request

public record PingRequest : IRequest<string>;

Notification

public record Notification(string Message) : INotification;

Handlers

public sealed class PingRequestHandler : IRequestHandler<PingRequest, string>
{
    public Task<string> HandleAsync(PingRequest request, CancellationToken ct)
        => Task.FromResult("pong");
}
public sealed class NotificationHandler : INotificationHandler<Notification>
{
    public async Task HandleAsync(Notification notification, CancellationToken ct)
        => Console.WriteLine($"A notification received - {notification.Message}");
}

Registering Handlers

services.AddTransient<IRequestHandler<PingRequest, string>, PingRequestHandler>();
services.AddTransient<INotificationHandler<Notification>, NotificationHandler>();

Registering the Mediator

services.AddFluxMediator();

Using the Mediator

Request
var result = await mediator.SendAsync(new PingRequest());
Notification
await mediator.PublishAsync(new Notification("You have a message."));

Architecture Goals

Flux.Mediator is built around:

  • Explicit contracts
  • No hidden service locators
  • Predictable execution flow
  • High performance without sacrificing readability
  • Compatibility with Clean Architecture, DDD and CQRS patterns

Benchmarks


BenchmarkDotNet v0.15.8, Linux Debian GNU/Linux 13 (trixie)
Intel Xeon CPU E5-2680 v4 2.40GHz, 1 CPU, 28 logical and 14 physical cores
.NET SDK 10.0.201
  [Host]     : .NET 10.0.5 (10.0.5, 10.0.526.15411), X64 RyuJIT x86-64-v3
  DefaultJob : .NET 10.0.5 (10.0.5, 10.0.526.15411), X64 RyuJIT x86-64-v3


Method Mean Error StdDev Gen0 Allocated
Request 96.42 ns 0.521 ns 0.435 ns 0.0105 192 B
Notification 87.55 ns 0.613 ns 0.544 ns 0.0061 112 B
Streaming 78.88 ns 1.154 ns 0.964 ns 0.0095 176 B

Testing

The mediator is designed to be tested in isolation:

var result = await mediator.SendAsync(new PingRequest());
Assert.Equal("pong", result);

Versioning

Flux.Mediator follows Semantic Versioning:

  • MAJOR → breaking changes
  • MINOR → new features without breaking
  • PATCH → fixes

NuGet

NuGet Package - Flux.Mediator

Author

Miguel Magno

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.2.0 120 3/21/2026
2.1.0 119 2/21/2026
2.0.2 128 2/14/2026
2.0.1 112 2/10/2026
2.0.0 120 2/10/2026
1.0.0 129 12/29/2025