SierraStack.Mediator is a lightweight, extensible in-process mediator for .NET. It provides a clean way to handle request/response messaging, supports pipeline behaviors, and is designed to be a modern, open-source alternative to MediatR — built for performance, simplicity, and testability.
💬 We're actively working on v0.2.0 and want your input!
📌 Join the conversation in this pinned issue
Let us know what you'd love to see next.
- ✅ Request/Response messaging with
IRequest<TResponse>andIRequestHandler<TRequest, TResponse> - ✅ In-process event publishing via
INotification - ✅ Built-in pipeline behaviors for:
- Logging
- Validation (FluentValidation + Custom Abstraction)
- Retry (Polly)
- Caching
- Performance measurement
- Exception handling
- ✅ Zero external dependencies in core
- ✅ Seamless integration with Microsoft.Extensions.DependencyInjection
Install from NuGet:
dotnet add package SierraStack.Mediator
dotnet add package SierraStack.Mediator.Behaviors
dotnet add package SierraStack.Mediator.Extensions.Microsoft📌 See NuGet Gallery for all available packages.
public class Ping : IRequest<string>
{
public string Message { get; set; } = "Ping!";
}public class PingHandler : IRequestHandler<Ping, string>
{
public Task<string> HandleAsync(Ping request, CancellationToken cancellationToken)
{
return Task.FromResult($"Pong: {request.Message}");
}
}services.AddSierraStackMediator(typeof(PingHandler).Assembly);
services.AddSierraStackBehaviors(); // optionalvar result = await mediator.SendAsync(new Ping());
// result => "Pong: Ping!"Install SierraStack.Mediator.Behaviors and register built-in behaviors:
services.AddSierraStackBehaviors();Or register them individually:
services
.AddLoggingBehavior()
.AddValidationBehavior(options =>
{
options.ThrowOnFailure = true;
options.OnFailure = failures =>
{
foreach (var failure in failures)
Console.WriteLine($"Validation failed: {failure.PropertyName} - {failure.ErrorMessage}");
};
});Validation uses a SierraStack-specific abstraction and can integrate with FluentValidation or custom providers.
All core components and built-in behaviors are covered with unit tests using xUnit. To run:
dotnet testLicensed under the MIT License.
Contributions, suggestions, and ideas are welcome! Please open an issue or pull request to get started.
https://github.com/sierrastack/SierraStack
📍 See the full roadmap for upcoming features and plans.
These benchmarks use BenchmarkDotNet to measure mediator performance across common scenarios.
| Scenario | Mean | Allocated |
|---|---|---|
| Simple Request | 633 ns | 952 B |
| + Logging Behavior | TBD | TBD |
| + Logging + Retry | TBD | TBD |
Run with:
dotnet run -c Release --project SierraStack.Mediator.Benchmarks