EricksonLopez.Mediator
dotnet-mediator · CQRS y Mensajería
En esta página (20 secciones)
1. Identidad, Nivel y Perfil de Madurez#
2. Propuesta de Valor y Problema que Resuelve#
High-throughput, zero-allocation CQRS mediator ecosystem for modern .NET (8, 9, 10). Features Roslyn compile-time dispatch, Native AOT-ready core (Partial across sub-packages), and zero-overhead pipeline extensions for caching, telemetry, and validation.
Los mediadores basados en reflexión asignan envoltorios y cadenas de delegados por petición, diluyen contratos Command/Query y fallan en Native AOT estricto.
3. Instalación Rápida#
Paquete principal: EricksonLopez.Mediator
dotnet add package EricksonLopez.Mediator --version 2.0.0<PackageReference Include="EricksonLopez.Mediator" Version="2.0.0" /><PackageVersion Include="EricksonLopez.Mediator" Version="2.0.0" />4. Métricas Verificadas del Ecosistema#
Instantánea recuperada UTC: 2026-12-01
5. Cuándo Usar y Cuándo NO Usar#
Cuándo usar
- Quieres contratos CQRS segregados ICommand<T> / IQuery<T> / INotification con despacho generado en compilación por Roslyn.
Cuándo NO usar
- Tus handlers solo emiten eventos simples sin pipelines de comando/consulta; usa EricksonLopez.Events.
6. Capacidades Principales e Invariantes de Diseño#
Contratos CQRS Segregados
Refuerza fronteras ICommand<T>, IQuery<T> e INotification con 13 analizadores Roslyn (ELM001–ELM013).
Continuaciones Struct y Adaptadores
Continuaciones INext<TResponse> por restricción struct más adaptadores para Caching, OpenTelemetry, Polly, Minimal APIs y FluentValidation.
7. Paquetes NuGet y Adaptadores Incluidos#
| ID del Paquete | Estado | NuGet / Local | TFMs | Estado AOT | Descargas | Descripción |
|---|---|---|---|---|---|---|
| EricksonLopez.MediatorPrincipal | Publicado | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Completo | 5,569 | High-performance, zero-allocation, AOT-compatible mediator pattern implementation for .NET 10. |
| EricksonLopez.Mediator.OpenTelemetry | Publicado | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Completo | 409 | OpenTelemetry distributed tracing and metrics instrumentation for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.FluentValidation | Publicado | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Incompatible | 332 | FluentValidation pipeline behavior and extensions for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.Testing | Publicado | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Completo | 298 | In-memory FakeMediator and testing doubles for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.Result | Publicado | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Completo | 292 | Result pattern integration and pipeline short-circuiting abstractions for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.RateLimiting | Publicado | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Completo | 283 | Rate limiting pipeline behavior for EricksonLopez.Mediator based on System.Threading.RateLimiting. |
| EricksonLopez.Mediator.AspNetCore | Publicado | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Completo | 262 | ASP.NET Core Minimal API endpoint mapping extensions for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.Polly | Publicado | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Completo | 261 | Polly v8 resilience policies and pipeline integration for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.GeneratorAnalizador / Generador | Publicado | v2.0.0 / v3.2.0 | netstandard2.0 | AOT: N/A (Analizador/Legado) | 247 | Source generator for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.Caching | No publicado | — / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Completo | 0 | Query caching and cache invalidation pipeline behaviors for EricksonLopez.Mediator. Supports stampede-protected multi-tier caching and Native AOT compatibility. |
8. Ejemplo Quick Start#
Basado en APIs públicas verificadas de EricksonLopez.Mediator. Compila con `<ImplicitUsings>disable</ImplicitUsings>` e importaciones explícitas.
using System;
using EricksonLopez.Mediator;
public sealed record CreateOrderCommand(string CustomerId, decimal Amount) : ICommand<Guid>;
public sealed record GetOrderByIdQuery(Guid OrderId) : IQuery<OrderDto?>;
public sealed record OrderDto(Guid OrderId, string CustomerId, decimal Amount, string Status);
public sealed record OrderCreatedEvent(Guid OrderId, string CustomerId) : INotification;9. Arquitectura y Flujo de Dependencias#
Renderizando diagrama…
flowchart LR lib_mediator["EricksonLopez.Mediator (L2)"] lib_result["EricksonLopez.Result (L0)"] lib_mediator -.-> lib_result lib_caching["EricksonLopez.Caching (L2)"] lib_mediator -.-> lib_caching lib_concurrency["EricksonLopez.Concurrency (L2)"] lib_concurrency -.-> lib_mediator lib_idempotency["EricksonLopez.Idempotency (L2)"] lib_idempotency -.-> lib_mediator lib_resilience["EricksonLopez.Resilience (L2)"] lib_resilience -.-> lib_mediator lib_transaction["EricksonLopez.Transaction (L2)"] lib_transaction --> lib_mediator lib_outbox["EricksonLopez.Outbox (L3)"] lib_outbox --> lib_mediator lib_security["EricksonLopez.Security (L3)"] lib_security -.-> lib_mediator lib_processes["EricksonLopez.Processes (L4)"] lib_processes --> lib_mediator
Ver descripción textual y tabla accesible
2 dependencias hacia librerías aguas arriba y 7 librerías dependientes aguas abajo verificadas en dependencies.json.
| Dirección | Librería | Nivel | Tipos de Relación |
|---|---|---|---|
| Aguas arriba | EricksonLopez.Result | L0 | Adaptador, Paquete NuGet |
| Aguas arriba | EricksonLopez.Caching | L2 | Adaptador |
| Aguas abajo | EricksonLopez.Concurrency | L2 | Adaptador, Paquete NuGet |
| Aguas abajo | EricksonLopez.Idempotency | L2 | Adaptador, Paquete NuGet |
| Aguas abajo | EricksonLopez.Resilience | L2 | Adaptador, Paquete NuGet |
| Aguas abajo | EricksonLopez.Transaction | L2 | Tiempo de compilación |
| Aguas abajo | EricksonLopez.Outbox | L3 | Adaptador, Tiempo de compilación, Paquete NuGet |
| Aguas abajo | EricksonLopez.Security | L3 | Adaptador |
| Aguas abajo | EricksonLopez.Processes | L4 | Tiempo de compilación, Paquete NuGet |
flowchart LR
lib_mediator["EricksonLopez.Mediator (L2)"]
lib_result["EricksonLopez.Result (L0)"]
lib_mediator -.-> lib_result
lib_caching["EricksonLopez.Caching (L2)"]
lib_mediator -.-> lib_caching
lib_concurrency["EricksonLopez.Concurrency (L2)"]
lib_concurrency -.-> lib_mediator
lib_idempotency["EricksonLopez.Idempotency (L2)"]
lib_idempotency -.-> lib_mediator
lib_resilience["EricksonLopez.Resilience (L2)"]
lib_resilience -.-> lib_mediator
lib_transaction["EricksonLopez.Transaction (L2)"]
lib_transaction --> lib_mediator
lib_outbox["EricksonLopez.Outbox (L3)"]
lib_outbox --> lib_mediator
lib_security["EricksonLopez.Security (L3)"]
lib_security -.-> lib_mediator
lib_processes["EricksonLopez.Processes (L4)"]
lib_processes --> lib_mediator10. Target Frameworks y Matriz Native AOT / Trimming#
Inspección MSBuild `.csproj` sobre 10 paquetes: 8 Full, 0 Partial, 1 Incompatible, 1 NotApplicable (analizadores/generadores).
| ID del Paquete | IsAotCompatible | EnableTrimAnalyzer | Estado AOT Verificado | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.Mediator | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.OpenTelemetry | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.FluentValidation | false | true | Incompatible | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.Testing | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.Result | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.RateLimiting | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.AspNetCore | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.Polly | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.Generator | false | false | NotApplicable | netstandard2.0 |
| EricksonLopez.Mediator.Caching | true | true | Full | net8.0, net9.0, net10.0 |
11. Dependencias Aguas Arriba y Dependientes Aguas Abajo#
Dependencias Aguas Arriba (2)
Dependientes Aguas Abajo (7)
12. Adaptadores Opcionales e Integraciones Externas#
Aristas de Adaptadores Internos y Paquetes de Integración
- EricksonLopez.Concurrency.Mediator (EricksonLopez.Concurrency)→ EricksonLopez.Mediator
- EricksonLopez.Idempotency.Mediator (EricksonLopez.Idempotency)→ EricksonLopez.Mediator
- EricksonLopez.Mediator.Caching→ EricksonLopez.Caching (EricksonLopez.Caching)
- EricksonLopez.Mediator.Caching→ EricksonLopez.Result (EricksonLopez.Result)
- EricksonLopez.Mediator.FluentValidation→ EricksonLopez.Result.FluentValidation (EricksonLopez.Result)
- EricksonLopez.Mediator.OpenTelemetry→ EricksonLopez.Result (EricksonLopez.Result)
- EricksonLopez.Mediator.Result→ EricksonLopez.Result (EricksonLopez.Result)
- EricksonLopez.Outbox.Mediator (EricksonLopez.Outbox)→ EricksonLopez.Mediator
- EricksonLopez.Resilience.Mediator (EricksonLopez.Resilience)→ EricksonLopez.Mediator
- EricksonLopez.Security.Mediator (EricksonLopez.Security)→ EricksonLopez.Mediator
Dependencias NuGet Externas Verificadas (6)
13. Resumen de Configuración y Registro en DI#
Puntos de Entrada DI y Configuración Verificados
MediatorHealthCheckExtensions.AddMediatorHealthCheckRegisters `MediatorHealthCheck` with the specified service collection.
MediatorEndpointRouteBuilderExtensions.MapCommand<TCommand, TResponse>Maps an HTTP POST endpoint for the specified command type `TCommand`.
MediatorEndpointRouteBuilderExtensions.MapQuery<TQuery, TResponse>Maps an HTTP GET endpoint for the specified query type `TQuery`.
CachingMediatorExtensions.AddMediatorCacheInvalidationRegisters the open generic `CacheInvalidationPipelineBehavior<TRequest, TResponse>` with the service collection.
CachingMediatorExtensions.AddMediatorCachingRegisters the open generic `CachingPipelineBehavior<TRequest, TResponse>` with the service collection.
ServiceCollectionExtensions.AddMediatorOpenTelemetryRegisters and configures OpenTelemetry instrumentation options for the mediator pipeline.
MediatorPollyExtensions.AddMediatorDefaultResiliencePipelineConfigures and registers a default Polly resilience pipeline for the mediator.
MediatorPollyExtensions.AddMediatorPollyRegisters the open generic `PollyResilienceBehavior<TRequest, TResponse>` with the service collection.
RateLimitingMediatorExtensions.AddMediatorRateLimitingRegisters the rate limiting pipeline behavior with the service collection.
MediatorFluentValidationExtensions.AddMediatorFluentValidationRegisters the open generic `ValidationPipelineBehavior<TRequest, TResponse>` as a pipeline behavior in the service collection.
MediatorFluentValidationExtensions.AddMediatorFluentValidationValidator<TValidator, TRequest>Registers a single FluentValidation validator explicitly, without assembly scanning.
MediatorFluentValidationExtensions.AddMediatorFluentValidatorsFromAssemblyDiscovers and registers all FluentValidation validators found in the specified assembly into the service collection.
Tipos Públicos y Contratos Clave
EricksonLopez.Mediator.DiscoverHandlersAttribute (class)Specifies a marker type whose containing assembly is scanned at compile time for mediator handlers and behaviors.
EricksonLopez.Mediator.HandlerLifetime (enum)Specifies the lifetime of a handler registration within the dependency injection container.
EricksonLopez.Mediator.ICommandHandler`2 (interface)Defines a handler for processing a command of type `TCommand`.
EricksonLopez.Mediator.ICommand`1 (interface)Defines a command that produces a response of type `TResponse`.
EricksonLopez.Mediator.IMediator (interface)Defines a mediator that combines message dispatching and notification publishing capabilities.
EricksonLopez.Mediator.INext (interface)Defines a callback delegate representing the next step in a notification processing pipeline.
EricksonLopez.Mediator.INext`1 (interface)Defines a callback delegate representing the next step in a request processing pipeline.
EricksonLopez.Mediator.INotification (interface)Defines a message that represents an event to be published to zero or more handlers.
EricksonLopez.Mediator.INotificationBehavior`1 (interface)Defines a cross-cutting behavior that surrounds notification handling within the mediator pipeline.
EricksonLopez.Mediator.INotificationHandler`1 (interface)Defines a handler for processing notifications of type `TNotification`.
EricksonLopez.Mediator.IPipelineBehavior`2 (interface)Defines a cross-cutting behavior that intercepts request processing within the mediator pipeline.
EricksonLopez.Mediator.IPublisher (interface)Defines a mechanism for publishing notification messages to registered handlers.
14. Benchmarks de Rendimiento Verificados#
Todas las mediciones verificadas provienen estrictamente de `BenchmarkDotNet.Artifacts` ejecutados sobre .NET RyuJIT (existen 0 ejecuciones NativeAOT en esta instantánea).
| Suite | Método | Runtime | Media (ns) | Asignado (B) | Estado |
|---|---|---|---|---|---|
| MediatorBenchmarks | DirectCall | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 0.177 | 0 | measured |
| MediatorBenchmarks | DirectCall | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.296 | 0 | measured |
| MediatorBenchmarks | DirectCall | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.33 | 0 | measured |
| MediatorBenchmarks | DirectCall | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.599 | 0 | measured |
| MediatorBenchmarks | DirectCall | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.601 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 11.186 | 24 | measured |
| MediatorBenchmarks | SendQuery_NoBehaviors | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 15.665 | 0 | measured |
| MediatorBenchmarks | SendQuery_NoBehaviors | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 15.811 | 0 | measured |
| MediatorBenchmarks | SendQuery_NoBehaviors | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 18.709 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 21.037 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 21.096 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 24.812 | 0 | measured |
| MediatorBenchmarks | SendQuery_NoBehaviors | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 25.745 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 26.185 | 0 | measured |
| MediatorBenchmarks | PublishNotification_OneHandler | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 40.324 | 24 | measured |
| MediatorBenchmarks | PublishNotification_OneHandler | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 41.371 | 24 | measured |
| MediatorBenchmarks | SendCommand_OneBehavior | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 45.81 | 0 | measured |
| MediatorBenchmarks | SendCommand_OneBehavior | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 47.159 | 0 | measured |
| MediatorBenchmarks | SendCommand_OneBehavior | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 47.186 | 0 | measured |
| MediatorBenchmarks | PublishNotification_OneHandler | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 54.349 | 24 | measured |
| MediatorBenchmarks | PublishNotification_OneHandler | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 58.007 | 24 | measured |
| MediatorBenchmarks | SendCommand_OneBehavior | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 58.711 | 0 | measured |
| MediatorBenchmarks | NestedSend | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 70.879 | 24 | measured |
| MediatorBenchmarks | NestedSend | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 71.734 | 24 | measured |
| MediatorBenchmarks | NestedSend | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 79.651 | 24 | measured |
15. Historial de Versiones y Estado NuGet vs Repositorio#
Desfase de versiones detectado: la última versión publicada en NuGet.org es v2.0.0, mientras el HEAD del repositorio local está en v3.2.0.
| Versión | Origen | Fecha de Publicación | Resumen |
|---|---|---|---|
| v2.0.0 ↗ | nuget | 2026-09-24 | Published EricksonLopez.Mediator 2.0.0 to NuGet.org. |
| v2.0.0 ↗ | github | 2026-09-24 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.Mediator` | `2.0.0` | | `EricksonLopez.Mediator.Generator` | `2.0.0` | | `EricksonLopez.Mediator.OpenTelemetry` | `2.0.0` | | `EricksonLopez.Mediator.Polly` | `2.0.0` | | `EricksonLopez.Mediator.Result` | `2.0.0` | | `EricksonLopez.Mediator.Testing` | `2.0.0` | | `EricksonLopez.Mediator.FluentValidat... |
| v1.0.0 ↗ | github | 2026-08-27 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.Mediator` | `1.0.0` | | `EricksonLopez.Mediator.Generator` | `1.0.0` | | `EricksonLopez.Mediator.OpenTelemetry` | `1.0.0` | | `EricksonLopez.Mediator.Polly` | `1.0.0` | | `EricksonLopez.Mediator.Result` | `1.0.0` | | `EricksonLopez.Mediator.Testing` | `1.0.0` | | `EricksonLopez.Mediator.FluentValidat... |
| v1.0.0 ↗ | nuget | 2026-08-27 | Published EricksonLopez.Mediator 1.0.0 to NuGet.org. |
16. Librerías Complementarias y Relacionadas#
Librerías en el mismo nivel, capa arquitectónica o vinculadas directamente mediante aristas de dependencia.
17. Documentación, API Reference y Enlaces del Portal#
Documentación Conceptual (Starlight) →
Referencia de API XML Extraída →
14 namespaces · 90 tipos · 280 miembros
Mapa de Dependencias del Ecosistema →
Centro de Aprendizaje y Manual →
Las páginas conceptuales por librería en Starlight se completan en M4; las páginas de API Reference en M3.2.
18. Repositorio Fuente, Licencia y Contribución#
Publicado bajo Licencia MIT. Todos los ensamblados cumplen los invariantes de compilación EricksonLopez.*: importaciones explícitas, firma fuerte (`EricksonLopez.snk`) y metadatos de autor en ASCII (`Erickson Lopez`).
19. Resolución de Problemas, Riesgos y Migración#
- Nota que aotStatus es Partial: EricksonLopez.Mediator.FluentValidation declara IsAotCompatible=false mientras el núcleo y otros 8 paquetes son Full AOT.
- Desfase de versiones detectado: la última versión publicada en NuGet.org es v2.0.0, mientras el HEAD del repositorio local está en v3.2.0.
20. Evidencia de Calidad y Verificación#
- Firma Fuerte (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- Extracción de Documentación XML
- Verificado (14 namespaces, 90 tipos, 280 miembros)
- Atributos MSBuild AOT / Trimming
- 8 Full / 0 Partial / 1 Incompatible / 1 N/A
- Artefactos BenchmarkDotNet
- 38 total (38 measured, 0 na_error)
Límites Explícitos de Verificación y Alcance
- Todas las mediciones verificadas provienen estrictamente de `BenchmarkDotNet.Artifacts` ejecutados sobre .NET RyuJIT (existen 0 ejecuciones NativeAOT en esta instantánea).
- 1 no publicados