refactor(hub): service public_stats 归组子包(#1761 首个增量) - #1768
refactor(hub): service public_stats 归组子包(#1761 首个增量)#1768DeliciousBuding wants to merge 2 commits into
Conversation
将 internal/service/public_stats.go 提取为 internal/service/publicstats/ 子包, 沿用 agentevent/、deliveryoutbox/ 等既有子包模式(doc.go + 原文件改 package 子句)。 选择 public_stats 的原因:耦合分析显示它与扁平 service 包的双向依赖均为 0 —— 不引用任何兄弟文件符号,也未被任何兄弟文件引用;外部消费者仅 3 处 (app/wiring.go、handler/public.go、handler/public_test.go),无生命周期钩子、 无接口注入、router 层零引用,是最安全的首个增量。 类型与方法签名保持不变(PublicStatsService.GetStats),纯归组无行为变更。 验证:go build ./... && go vet ./... && go test ./internal/service/... -short 全绿。 Co-authored-by: Cursor <cursor@vectorcontrol.tech>
|
Warning Review limit reached
Next review available in: 22 minutes Limit details: You’ve used the included review currently available. 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 within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day 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 (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe public statistics service now resides in the ChangesPublic statistics package migration
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change only reorganizes the public statistics service and updates its consumers without changing behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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 |
public_stats 归组为 service/publicstats 子包后,tests/integration/setup_test.go 仍引用旧的 service.NewPublicStatsService,导致 Backend integration 编译失败。 更新为 publicstats.NewPublicStatsService 并按字母序补 import。 验证:go test -c -tags integration 编译通过;go build/vet ./... 全绿; go test ./internal/service/... -short 全绿。 Co-authored-by: Cursor <cursor@vectorcontrol.tech>
变更内容(#1761 首个安全增量)
将
hub-server/internal/service/public_stats.go提取为子包internal/service/publicstats/,沿用既有子包模式(agentevent/、deliveryoutbox/、dispatchsvc/:doc.go + 原文件仅改 package 子句)。类型名与方法签名保持不变(PublicStatsService.GetStats),纯目录归组,无行为变更。同步更新的外部消费者仅 3 处:
internal/app/wiring.go(构造调用 + import)internal/handler/public.go(字段与构造参数类型限定符)internal/handler/public_test.go(构造调用 + import)耦合分析(为何选 public_stats)
对 11 个候选文件统计与扁平
service包的双向依赖(引用兄弟符号数 / 被兄弟引用数):public_stats 是零耦合候选中最完整的"服务域"(struct + 构造器 + 方法,经 app 组装被 handler 消费),且无生命周期钩子、无接口注入、router 层零引用 —— 首增量风险最小。
验证(全部通过)
go build ./...✅go vet ./...✅go test ./internal/service/... -short✅(14 个包全绿)go test ./internal/handler/ -run TestPublicStats✅剩余域(后续增量建议)