mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
- 修复 CqrsDispatcher 的 pipeline invoker 重复创建,并补齐缓存线程模型文档 - 优化 CQRS 与 generator 回归测试的并发保护和稳定语义断言 - 更新 cqrs-rewrite 跟踪与 trace,记录 RP-062 的 PR review follow-up 验证结果
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using System.Threading;
|
|
|
|
namespace GFramework.Cqrs.Tests.Cqrs;
|
|
|
|
/// <summary>
|
|
/// 记录双行为 pipeline 的实际执行顺序。
|
|
/// </summary>
|
|
internal static class DispatcherPipelineOrderState
|
|
{
|
|
private static readonly Lock SyncRoot = new();
|
|
private static readonly List<string> _steps = [];
|
|
|
|
/// <summary>
|
|
/// 获取按执行顺序追加的步骤快照。
|
|
/// 共享状态通过 <c>SyncRoot</c> 串行化,避免并行行为测试互相污染步骤列表。
|
|
/// </summary>
|
|
public static IReadOnlyList<string> Steps
|
|
{
|
|
get
|
|
{
|
|
lock (SyncRoot)
|
|
{
|
|
return _steps.ToArray();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 记录一个新的 pipeline 执行步骤。
|
|
/// </summary>
|
|
/// <param name="step">要追加的步骤名称。</param>
|
|
public static void Record(string step)
|
|
{
|
|
lock (SyncRoot)
|
|
{
|
|
_steps.Add(step);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清空当前记录,供下一次断言使用。
|
|
/// </summary>
|
|
public static void Reset()
|
|
{
|
|
lock (SyncRoot)
|
|
{
|
|
_steps.Clear();
|
|
}
|
|
}
|
|
}
|