// 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;
///
/// 处理 ,用于验证零管道 stream 的 dispatcher 缓存路径。
///
internal sealed class DispatcherZeroPipelineStreamHandler : IStreamRequestHandler
{
///
/// 返回一个单元素异步流,便于在缓存测试中最小化处理噪音。
///
/// 当前零管道 stream 请求。
/// 用于终止异步枚举的取消令牌。
/// 只包含一个元素的异步响应流。
public async IAsyncEnumerable Handle(
DispatcherZeroPipelineStreamRequest request,
[EnumeratorCancellation] CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(request);
cancellationToken.ThrowIfCancellationRequested();
yield return 1;
}
}