refactor(hub): dispatch 家族收敛为 dispatchsvc 包并去 Setter 装配 - #1671
refactor(hub): dispatch 家族收敛为 dispatchsvc 包并去 Setter 装配#1671DeliciousBuding wants to merge 1 commit into
Conversation
hub Top 1:agent_dispatch 8 文件散装(~1500 行)从平铺 service 包
收敛到 internal/service/dispatchsvc:
1. 包边界:DispatchService 家族整体平移(git mv 保留历史),
DispatchTask / RedispatchDelivery 显式导出作为跨包缝,AgentService
保持原有对外 API 不变(handler/app 层零改动)。
2. 传输层去耦(hub Top 3 联动):
- ManagerPort/ConnPort/FramePort/DeliveryResultPort 取代原来直接
引用 *ws.Conn / ws.Frame / ws.DeliveryResult 的 dispatchWS 端口,
dispatchsvc 不再 import internal/ws;service 层新增 wsManagerAdapter
完成映射。
- RelayPort(CreateCommand 仅返回 error)取代 relayDispatcher,
relayServiceAdapter 丢弃 dispatch 不消费的命令元数据。
3. 装配收敛:删除 DispatchService 的 5 个 Setter(SetBus/SetCache/
SetManager/SetOutbox/SetRelay,零生产调用点),构造函数一次性注入;
端口组合测试改写为构造注入断言。
4. 归属收拢:resolveDispatchCache/isNilCache、redispatchTarget 随家族
迁入 dispatchsvc;dispatchRedispatcher 适配器走导出 RedispatchDelivery
缝。
5. 测试随迁:breaker/edge_http 测试与端口 mock 迁入 dispatchsvc 包
(白盒访问保留),service 侧集成测试改用导出缝。
lint 欠账顺带清偿:auth_test.go 夹具变量重命名消除 G101(#1670 清偿
后从 max-same-issues 封顶浮出的下一处);hub-lint-baseline 对移动的
gocognit 条目做外科式路径更新(2 行 diff,不整表重建以保持 CI 环境
基线稳定)。
验证:go build/vet/staticcheck 全绿;go test ./... -short -race 通过;
hub-layering / hub-pure-packages / outbound-hygiene / dto / openapi /
lint-ratchet 全部 PASS;git diff --check 干净。
Co-authored-by: Cursor <cursor@vectorcontrol.tech>
|
Warning Review limit reached
Next review available in: 45 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (25)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
hub Top 1:
agent_dispatch8 文件散装(~1500 行)从平铺 service 包收敛到internal/service/dispatchsvc。DispatchTask/RedispatchDelivery显式导出作为跨包缝;AgentService 对外 API 不变(handler/app 层零改动)。ManagerPort/ConnPort/FramePort/DeliveryResultPort取代直接引用*ws.Conn/ws.Frame/ws.DeliveryResult的 dispatchWS 端口——dispatchsvc 不再 import internal/ws;service 层新增wsManagerAdapter映射。RelayPort(仅返回 error)取代 relayDispatcher,relayServiceAdapter丢弃 dispatch 不消费的命令元数据。resolveDispatchCache/isNilCache/redispatchTarget随家族迁入 dispatchsvc;dispatchRedispatcher适配器走导出RedispatchDelivery缝。lint 欠账顺带清偿:auth_test.go 夹具变量重命名消除 G101(#1670 清偿后从 max-same-issues 封顶浮出的下一处);hub-lint-baseline 对移动的 gocognit 条目做外科式路径更新(2 行 diff,刻意不整表重建——本地 Windows lint 输出与 CI 基线环境有差异,见 Wave-10 注释)。
Test plan
go build/go vet/ staticcheck 全绿go test ./... -count=1 -short -race -coverprofile通过(CI 同款);dispatchsvc 包全过git diff --check干净后续队列(依赖本 PR 的收尾)
app/events.gopending 重放下沉(hub Top 2)