Vali-Mediator
Vali-Mediator is a lightweight .NET library that implements the Mediator pattern with full CQRS support. It provides a clean separation between request senders and request handlers, a powerful pipeline for cross-cutting concerns, and a rich ecosystem of extension packages.
Why Vali-Mediator?
- Zero external dependencies in the core package (only
Microsoft.Extensions.DependencyInjection.Abstractions) - Targets .NET 7, 8, and 9 — multi-target from one package
- Result pattern built-in — no exceptions for business logic failures
- Extensible pipeline — add behaviors, pre/post processors without touching business code
- Complete ecosystem — resilience, caching, observability, and idempotency as optional packages
Dispatch Flow
loading...Package Ecosystem
Key Features
Requests & CQRS
IRequest<TResponse>+IRequestHandler<TRequest, TResponse>- Void shorthand:
IRequest→IRequest<Unit> SendOrDefault— returnsdefaultwhen no handler registeredSendAll— parallel execution viaTask.WhenAll
Notifications
- Fan-out to N handlers via
INotification - Priority-ordered execution
PublishStrategy: Sequential, Parallel, or ResilientParallelINotificationFilter<T>— conditionally skip handlers
Pipeline
IPipelineBehavior<TRequest, TResponse>for requestsIPipelineBehavior<TDispatch>for notifications/fire-and-forget- Auto-discovered pre/post processors
- Declarative timeout via
IHasTimeout - Dead letter queue for failed notifications
Result Pattern
Result<T>andResult(void) — readonly structsErrorTypeenum maps to HTTP status codes- Functional operations:
Map,Bind,Tap,Match,OnFailure
Streaming
IStreamRequest<T>+CreateStream()→IAsyncEnumerable<T>
Version
Current stable version: 2.0.0