mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 08:44:29 +08:00
- 新增ContextAwareMediatorCommandExtensions提供命令扩展方法兼容性支持 - 新增ContextAwareMediatorQueryExtensions提供查询扩展方法兼容性支持 - 添加LoggerFactoryResolver实现全局日志工厂访问入口 - 实现TypeForwarders将核心类型转发到正确程序集 - 添加MediatorCompatibilityDeprecationTests验证弃用策略 - 扩展LoggerFactoryTests覆盖并发初始化和回退逻辑 - 迁移CommandBase到Core.Cqrs.Command命名空间 - 移动LoggingBehavior到GFramework.Cqrs.Cqrs.Behaviors - 添加AbstractStreamQueryHandler支持流式查询处理 - 创建NotificationBase提供通知基类实现
41 lines
2.0 KiB
C#
41 lines
2.0 KiB
C#
// Copyright (c) 2026 GeWuYou
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
using GFramework.Cqrs.Abstractions.Cqrs;
|
|
using GFramework.Cqrs.Abstractions.Cqrs.Query;
|
|
|
|
namespace GFramework.Cqrs.Cqrs.Query;
|
|
|
|
/// <summary>
|
|
/// 为流式查询处理器提供共享的 CQRS 上下文访问基类。
|
|
/// </summary>
|
|
/// <typeparam name="TQuery">流式查询类型,必须实现 <see cref="IStreamQuery{TResponse}" />。</typeparam>
|
|
/// <typeparam name="TResponse">流式查询响应元素类型。</typeparam>
|
|
/// <remarks>
|
|
/// 该基类复用 <see cref="CqrsContextAwareHandlerBase" /> 的上下文注入能力,并实现
|
|
/// <see cref="IStreamRequestHandler{TQuery,TResponse}" /> 契约,让派生类只需聚焦于结果流的生成逻辑。
|
|
/// 适用于需要逐步产出大量结果或长生命周期响应流的查询场景。
|
|
/// </remarks>
|
|
public abstract class AbstractStreamQueryHandler<TQuery, TResponse> : CqrsContextAwareHandlerBase,
|
|
IStreamRequestHandler<TQuery, TResponse>
|
|
where TQuery : IStreamQuery<TResponse>
|
|
{
|
|
/// <summary>
|
|
/// 处理流式查询并返回异步可枚举的响应序列。
|
|
/// </summary>
|
|
/// <param name="query">要处理的流式查询对象。</param>
|
|
/// <param name="cancellationToken">用于停止结果流生成的取消令牌。</param>
|
|
/// <returns>按需生成的异步响应序列。</returns>
|
|
public abstract IAsyncEnumerable<TResponse> Handle(TQuery query, CancellationToken cancellationToken);
|
|
}
|