EricksonLopez.Mediator — Visión General
EricksonLopez.Mediator (2.0.0 en NuGet, L2) es un mediador CQRS generado en compilación que ejecuta comandos, consultas, notificaciones y streams basados en ValueTask sin reflexión en tiempo de ejecución.
- Registro DI y despacho generados (
EricksonLopez.Mediator.Generator): EmiteAddEricksonLopezMediator()y cableado fuertemente tipado en compilación junto con diagnósticosELM001–ELM013. - Continuaciones sin asignaciones:
IPipelineBehavior<in TRequest, TResponse>restringewhere TNext : struct, INext<TResponse>para invocarnext.InvokeAsync()sin clausuras en el heap. StaticMediatory límite de recursión:StaticMediatorpermite despacho AOT sin contenedor DI (Freeze(),SendCommand,SendQuery,Publish), yMaxRecursionDepthBehaviorevita bucles infinitos.- Puente Polly obsoleto (
v2.0.0):EricksonLopez.Mediator.Pollyestá marcado como[Obsolete](ADR-036) — usaEricksonLopez.Resilience.Mediator.
Renderizando diagrama…
flowchart LR App["Caller -> ISender"] --> Gen["Generated Dispatch (Scoped)"] Gen --> B1["IPipelineBehavior<TReq, TRes> (INext<TRes> struct)"] B1 -- next.InvokeAsync() --> H["ICommandHandler / IQueryHandler -> ValueTask<TRes>"]
Ver descripción textual y tabla accesible
ISender enruta comandos y consultas a través de continuaciones IPipelineBehavior restringidas por struct (next.InvokeAsync()) hacia manejadores generados ICommandHandler o IQueryHandler.
flowchart LR
App["Caller -> ISender"] --> Gen["Generated Dispatch (Scoped)"]
Gen --> B1["IPipelineBehavior<TReq, TRes> (INext<TRes> struct)"]
B1 -- next.InvokeAsync() --> H["ICommandHandler / IQueryHandler -> ValueTask<TRes>"]Paquetes y Estado Native AOT (9 / 10 Publicados)
Sección titulada «Paquetes y Estado Native AOT (9 / 10 Publicados)»9 de 10 paquetes están publicados en 2.0.0 en NuGet (7,953 descargas totales; localVersion: 3.2.0 en disco), mientras EricksonLopez.Mediator.Caching permanece sin publicar (3.2.0 solo local). Estado AOT global Partial (8 Full, 1 Incompatible, 1 NotApplicable):
- Publicados (
2.0.0, AOTFull, 7 paquetes):Mediator(5,569),OpenTelemetry(409),Testing(298),Result(292),RateLimiting(283),AspNetCore(262),Polly(261,[Obsolete]). - Publicados (
2.0.0, AOTIncompatible, 1 paquete):Mediator.FluentValidation(332,IsAotCompatible=falsepor escaneo de ensamblados). - Publicado (
2.0.0, RoslynNotApplicable, 1 paquete):Mediator.Generator(247,netstandard2.0). - Sin publicar (Local
3.2.0, AOTFull, 1 paquete):Mediator.Caching(0descargas).
Medidos desde BenchmarkDotNet.Artifacts (38 filas medidas, 0 na_error) en .NET 8.0.31, .NET 9.0.20, .NET 10.0.10 y .NET 10.0.12 X64 RyuJIT (sin reportes NativeAOT):
MediatorBenchmarks.DirectCall: 0.1769 ns / 0 B (.NET 10.0.10RyuJITx86-64-v4)MediatorBenchmarks.SendCommand_NoBehaviors: 11.1858 ns / 24 B (.NET 10.0.10RyuJITx86-64-v4)MediatorBenchmarks.SendQuery_NoBehaviors: 15.6645 ns / 0 B (.NET 10.0.12RyuJITx86-64-v3)MediatorBenchmarks.SendCommand_OneBehavior: 47.1593 ns / 0 B (.NET 10.0.12RyuJITx86-64-v3)MediatorBenchmarks.SendCommand_FiveBehaviors: 183.9336 ns / 0 B (.NET 10.0.12RyuJITx86-64-v3)MediatorBenchmarks.PublishNotification_OneHandler: 40.3239 ns / 24 B (FiveHandlers: 199.3251 ns / 120 B;Parallel: 183.3404 ns / 192 B)