refactor(gateway): 传输层抽象与分层 ActionRegistry(Step 1)#475
Merged
phantom5099 merged 2 commits into1024XEngineer:mainfrom Apr 27, 2026
Merged
refactor(gateway): 传输层抽象与分层 ActionRegistry(Step 1)#475phantom5099 merged 2 commits into1024XEngineer:mainfrom
phantom5099 merged 2 commits into1024XEngineer:mainfrom
Conversation
引入轻量级 TransportAdapter 接口和分层的 ActionRegistry, 为后续 gRPC、飞书适配器、CLI 诊断等扩展扫清架构障碍。 变更内容: - 新增 TransportAdapter 接口(contracts.go),Server 与 NetworkServer 隐式实现,无需修改内部逻辑 - 新增分层 ActionRegistry(registry.go),core 层保护 15 个 内置 handler 不可覆盖,extended 层供外部包动态注册 - bootstrap.go 分发链路从硬编码 var map 切换至 defaultRegistry.Lookup,扩展动作可通过 RegisterAction/MustRegisterAction 注册 - CLI 装配层统一使用 []TransportAdapter 遍历启动,保留 IPC 主阻塞、HTTP goroutine 降级语义 - 清理 CLI 层本地 interface 定义,统一复用 gateway 包类型 - 补齐 registry 行为测试与编译期接口断言
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Collaborator
|
可以,方案上和代码实施我看着基本一致 |
Collaborator
|
/review |
| logger.Printf("gateway ipc listen address: %s", ipcServer.ListenAddress()) | ||
| logger.Printf("gateway network listen address: %s", networkServer.ListenAddress()) | ||
| for index, adapter := range transportAdapters { | ||
| logger.Printf("gateway %s listen address: %s", transportNames[index], adapter.ListenAddress()) |
There was a problem hiding this comment.
transportAdapters 与 transportNames 通过索引绑定(并在后续日志中继续使用该假设),后续新增/重排适配器时很容易出现长度不一致导致 panic,或日志名称与真实适配器不一致。建议改为 []struct{name string; adapter gateway.TransportAdapter} 这类单一数据结构,避免并行切片耦合。
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
背景
NeoCode 网关层当前的 transport 协议(IPC/HTTP)和 action handler 均以硬编码方式耦合在核心文件中。每次新增接入面(gRPC)或新增能力(飞书、CLI 诊断),都需要直接修改 gateway_commands.go 和 bootstrap.go,违背"对扩展开放、对修改封闭"原则。
##做了什么
验证
影响范围
Closes #474