mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-06 16:16:44 +08:00
- 优化 CqrsDispatcher 的 request pipeline 路径,按请求类型与行为数量缓存 typed executor 形状并在单次分发中绑定当前 handler 与 behaviors - 补充 dispatcher 缓存回归测试,覆盖 pipeline executor 的首次创建、后续复用与行为顺序稳定
28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
using GFramework.Cqrs.Abstractions.Cqrs;
|
|
|
|
namespace GFramework.Cqrs.Tests.Cqrs;
|
|
|
|
/// <summary>
|
|
/// 作为内层行为验证缓存 executor 复用后仍保持注册顺序。
|
|
/// </summary>
|
|
internal sealed class DispatcherPipelineOrderInnerBehavior : IPipelineBehavior<DispatcherPipelineOrderCacheRequest, int>
|
|
{
|
|
/// <summary>
|
|
/// 记录内层行为的前后执行节点。
|
|
/// </summary>
|
|
/// <param name="request">当前请求。</param>
|
|
/// <param name="next">下一个处理阶段。</param>
|
|
/// <param name="cancellationToken">取消令牌。</param>
|
|
/// <returns>下游处理器结果。</returns>
|
|
public async ValueTask<int> Handle(
|
|
DispatcherPipelineOrderCacheRequest request,
|
|
MessageHandlerDelegate<DispatcherPipelineOrderCacheRequest, int> next,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
DispatcherPipelineOrderState.Steps.Add("Inner:Before");
|
|
var result = await next(request, cancellationToken).ConfigureAwait(false);
|
|
DispatcherPipelineOrderState.Steps.Add("Inner:After");
|
|
return result;
|
|
}
|
|
}
|