-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/Implement CQRS runtime integration for legacy compatibility #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
017e689
feat(cqrs): 补齐请求生命周期基准矩阵
GeWuYou d7293aa
refactor(core): 统一旧版命令查询到Cqrs运行时
GeWuYou 6056159
fix(core): 收口 legacy cqrs bridge 评审问题
GeWuYou dc3bd37
fix(core): 收口 legacy bridge 同步评审问题
GeWuYou cca4130
chore(cqrs-rewrite): 同步PR334评审复核状态
GeWuYou 44d1a89
test(core): 补强 legacy bridge 上下文断言
GeWuYou ffb0a8a
fix(core): 收窄 legacy bridge 上下文回退异常边界
GeWuYou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
GFramework.Core.Tests/Architectures/LegacyArchitectureBridgeAsyncQuery.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright (c) 2025-2026 GeWuYou | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using GFramework.Core.Abstractions.Architectures; | ||
| using GFramework.Core.Abstractions.Query; | ||
| using GFramework.Core.Rule; | ||
|
|
||
| namespace GFramework.Core.Tests.Architectures; | ||
|
|
||
| /// <summary> | ||
| /// 用于验证 legacy 异步查询桥接时也会显式注入当前架构上下文。 | ||
| /// </summary> | ||
| public sealed class LegacyArchitectureBridgeAsyncQuery : ContextAwareBase, IAsyncQuery<int> | ||
| { | ||
| /// <summary> | ||
| /// 获取执行期间观察到的上下文实例。 | ||
| /// </summary> | ||
| public IArchitectureContext? ObservedContext { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// 执行异步查询并返回测试结果。 | ||
| /// </summary> | ||
| public Task<int> DoAsync() | ||
| { | ||
| ObservedContext = ((GFramework.Core.Abstractions.Rule.IContextAware)this).GetContext(); | ||
| return Task.FromResult(64); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
GFramework.Core.Tests/Architectures/LegacyArchitectureBridgeCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright (c) 2025-2026 GeWuYou | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using GFramework.Core.Abstractions.Architectures; | ||
| using GFramework.Core.Abstractions.Command; | ||
| using GFramework.Core.Rule; | ||
|
|
||
| namespace GFramework.Core.Tests.Architectures; | ||
|
|
||
| /// <summary> | ||
| /// 用于验证 legacy 命令桥接时会把当前 <see cref="IArchitectureContext" /> 注入到命令对象。 | ||
| /// </summary> | ||
| public sealed class LegacyArchitectureBridgeCommand : ContextAwareBase, ICommand | ||
| { | ||
| /// <summary> | ||
| /// 获取执行期间观察到的上下文实例。 | ||
| /// </summary> | ||
| public IArchitectureContext? ObservedContext { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// 获取当前命令是否已经执行。 | ||
| /// </summary> | ||
| public bool Executed { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// 执行命令并记录 bridge handler 注入的上下文。 | ||
| /// </summary> | ||
| public void Execute() | ||
| { | ||
| Executed = true; | ||
| ObservedContext = ((GFramework.Core.Abstractions.Rule.IContextAware)this).GetContext(); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
GFramework.Core.Tests/Architectures/LegacyArchitectureBridgeCommandWithResult.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright (c) 2025-2026 GeWuYou | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using GFramework.Core.Abstractions.Architectures; | ||
| using GFramework.Core.Abstractions.Command; | ||
| using GFramework.Core.Rule; | ||
|
|
||
| namespace GFramework.Core.Tests.Architectures; | ||
|
|
||
| /// <summary> | ||
| /// 用于验证 legacy 带返回值命令桥接时会沿用统一 runtime。 | ||
| /// </summary> | ||
| public sealed class LegacyArchitectureBridgeCommandWithResult : ContextAwareBase, ICommand<int> | ||
| { | ||
| /// <summary> | ||
| /// 获取执行期间观察到的上下文实例。 | ||
| /// </summary> | ||
| public IArchitectureContext? ObservedContext { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// 执行命令并返回测试结果。 | ||
| /// </summary> | ||
| public int Execute() | ||
| { | ||
| ObservedContext = ((GFramework.Core.Abstractions.Rule.IContextAware)this).GetContext(); | ||
| return 42; | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
GFramework.Core.Tests/Architectures/LegacyArchitectureBridgeQuery.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright (c) 2025-2026 GeWuYou | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using GFramework.Core.Abstractions.Architectures; | ||
| using GFramework.Core.Abstractions.Query; | ||
| using GFramework.Core.Rule; | ||
|
|
||
| namespace GFramework.Core.Tests.Architectures; | ||
|
|
||
| /// <summary> | ||
| /// 用于验证 legacy 查询桥接时会把当前 <see cref="IArchitectureContext" /> 注入到查询对象。 | ||
| /// </summary> | ||
| public sealed class LegacyArchitectureBridgeQuery : ContextAwareBase, IQuery<int> | ||
| { | ||
| /// <summary> | ||
| /// 获取执行期间观察到的上下文实例。 | ||
| /// </summary> | ||
| public IArchitectureContext? ObservedContext { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// 执行查询并返回测试结果。 | ||
| /// </summary> | ||
| public int Do() | ||
| { | ||
| ObservedContext = ((GFramework.Core.Abstractions.Rule.IContextAware)this).GetContext(); | ||
| return 24; | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
GFramework.Core.Tests/Architectures/LegacyBridgePipelineTracker.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Copyright (c) 2025-2026 GeWuYou | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using System.Threading; | ||
|
|
||
| namespace GFramework.Core.Tests.Architectures; | ||
|
|
||
| /// <summary> | ||
| /// 为 legacy bridge pipeline 回归测试保存跨泛型闭包共享的计数状态。 | ||
| /// </summary> | ||
| public static class LegacyBridgePipelineTracker | ||
| { | ||
| private static int _invocationCount; | ||
|
|
||
| /// <summary> | ||
| /// 获取当前进程内被识别为 legacy bridge request 的 pipeline 命中次数。 | ||
| /// </summary> | ||
| public static int InvocationCount => Volatile.Read(ref _invocationCount); | ||
|
|
||
| /// <summary> | ||
| /// 重置计数器。 | ||
| /// </summary> | ||
| public static void Reset() | ||
| { | ||
| Volatile.Write(ref _invocationCount, 0); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// 若当前请求类型属于 Core legacy bridge request,则记录一次命中。 | ||
| /// </summary> | ||
| public static void Record(Type requestType) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(requestType); | ||
|
|
||
| if (string.Equals(requestType.Namespace, "GFramework.Core.Cqrs", StringComparison.Ordinal) && | ||
| requestType.Name.Contains("Legacy", StringComparison.Ordinal)) | ||
| { | ||
| Interlocked.Increment(ref _invocationCount); | ||
| } | ||
| } | ||
| } | ||
|
GeWuYou marked this conversation as resolved.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.