mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-11 04:04:29 +08:00
- 优化 CqrsDispatcher 的 CreateStream 热路径,按 dispatcher 实例缓存 stream pipeline behavior 的服务可见性 - 新增 stream presence cache 回归与最小测试桩,锁住同容器共享、跨容器隔离的缓存语义 - 更新 cqrs-rewrite 恢复文档并补充本轮 stream benchmark 验证结果
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
// Copyright (c) 2025-2026 GeWuYou
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading;
|
|
using GFramework.Cqrs.Abstractions.Cqrs;
|
|
|
|
namespace GFramework.Cqrs.Tests.Cqrs;
|
|
|
|
/// <summary>
|
|
/// 处理 <see cref="DispatcherZeroPipelineStreamRequest" />,用于验证零管道 stream 的 dispatcher 缓存路径。
|
|
/// </summary>
|
|
internal sealed class DispatcherZeroPipelineStreamHandler : IStreamRequestHandler<DispatcherZeroPipelineStreamRequest, int>
|
|
{
|
|
/// <summary>
|
|
/// 返回一个单元素异步流,便于在缓存测试中最小化处理噪音。
|
|
/// </summary>
|
|
/// <param name="request">当前零管道 stream 请求。</param>
|
|
/// <param name="cancellationToken">用于终止异步枚举的取消令牌。</param>
|
|
/// <returns>只包含一个元素的异步响应流。</returns>
|
|
public async IAsyncEnumerable<int> Handle(
|
|
DispatcherZeroPipelineStreamRequest request,
|
|
[EnumeratorCancellation] CancellationToken cancellationToken)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(request);
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
yield return 1;
|
|
}
|
|
}
|