mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-08 17:44:29 +08:00
- 修复 legacy 同步 bridge 的 runtime 等待方式,统一通过共享 helper 隔离同步上下文并收口重复 dispatch-context 解析逻辑 - 补充 legacy async command bridge 的取消可见性,并更新 ICqrsRuntime 与相关入口的契约说明 - 新增 bridge 回归测试并更新 cqrs-rewrite active tracking,覆盖同步上下文隔离、测试容器释放与取消语义
27 lines
998 B
C#
27 lines
998 B
C#
// Copyright (c) 2025-2026 GeWuYou
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
using GFramework.Cqrs.Abstractions.Cqrs;
|
|
|
|
namespace GFramework.Core.Cqrs;
|
|
|
|
/// <summary>
|
|
/// 处理 legacy 异步无返回值命令的 bridge handler。
|
|
/// </summary>
|
|
internal sealed class LegacyAsyncCommandDispatchRequestHandler
|
|
: LegacyCqrsDispatchHandlerBase, IRequestHandler<LegacyAsyncCommandDispatchRequest, Unit>
|
|
{
|
|
/// <inheritdoc />
|
|
public async ValueTask<Unit> Handle(
|
|
LegacyAsyncCommandDispatchRequest request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(request);
|
|
// Legacy ExecuteAsync contract does not accept CancellationToken; use WaitAsync so the caller can still observe cancellation promptly.
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
PrepareTarget(request.Command);
|
|
await request.Command.ExecuteAsync().WaitAsync(cancellationToken).ConfigureAwait(false);
|
|
return Unit.Value;
|
|
}
|
|
}
|