style: 日志与输出对齐成熟 Go 写法,信号信道改 struct{} - #278
Conversation
日志:slog 已按级别输出,消息里再写 [ERROR]/[WARN] 是重复;handlePut: 这类函数名前缀
则应由结构化字段承载。7 处改为「简短小写英文短语 + 字段」,与仓库其余 104 条日志一致:
"[WARN] handlePut: data too short" → "put frame too short" + len
"[ERROR] handlePut: forward failed" → "forward put to owner failed" + owner/error
"[cluster] failover: node removed" → "node removed from ring" + node
唯一一条中文日志(scan 结果截断)改为英文,日志语言由 110:1 变为 111:0 全英文。
面向用户的输出:交互式 CLI 去掉 ❌/✅ emoji。CLI 自身的中文行文保持不变——它面向人,
与面向机器的日志是两套受众,不应混为一谈。
信号信道 chan bool → chan struct{}:Engine.flushCh、Engine.compactCh、Raft.electionCh、
Raft.heartbeatCh 的接收端一律丢弃该值(case <-ch:),那个 bool 不携带任何信息。
raft 的 voteCh 保持 chan bool——它真的在传值(voteGranted := <-voteCh)。
收敛导出面积:以下字段包外零引用,改为包内私有——Engine.FlushChan(同时与 compactCh
命名对齐为 flushCh)、MsgHandle.TaskQueue/WorkerPoolSize、Server.ExitCh/IPVersion。
Server.IP/Port/Name 保持导出:集成测试确实在外部设置它们。
过程记录:批量改名时正则把 config.G.WorkerPoolSize 也改掉了——同名但不同物(那是对外
可见的配置字段),已改回。
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 16 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: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
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 |
🐯 BanGD 数据库内核评审整体风险:🟢 低 变更总结:这是一个纯风格/一致性 PR,不动任何并发、存储、格式不变量。四类改动:① 日志消息去掉冗余级别前缀(
架构问题(共 2 项)
普通问题(共 1 项)💡 [建议 · 命名一致性]
本次评审消耗 token:共 91824 tokens(输入 78861,输出 3235,缓存命中 9728,缓存写入 0)|维度 [concurrency, memory, lock, storage, performance]|补充阅读周边文件 [bannet/connection.go]|对抗式复核 3 票/条,过滤疑似误报 0 条 |
「风格不够老道」这次我先把它变成可检查的痕迹,再逐条修。前几轮已处理过注释叙述历史、装饰标记、术语混用;本轮量化后发现注释形态其实已经健康(218 处单行、仅 7 处 ≥4 行、辩论式措辞 1 处),剩下的生手痕迹在别处。
① 日志:slog 已分级,消息里再写级别是重复
[WARN]与slog.Warn重复;handlePut:这类函数名前缀应由结构化字段承载,而不是拼进消息文本。7 处改为「简短小写英文短语 + 字段」,与仓库其余 104 条日志一致:[WARN] handlePut: data too shortput frame too short+len[ERROR] handlePut: forward failedforward put to owner failed+owner/error[cluster] failover: node removed from ringnode removed from ring+node唯一一条中文日志(scan 结果截断)改为英文。日志语言由 110:1 变为 111:0 全英文——同一套日志里混语言是最显眼的不一致。
② 面向用户的输出:去掉 emoji
交互式 CLI 里的
❌ 错误:/✅ OK改为纯文本。CLI 自身的中文行文保持不变:它面向人,与面向机器的日志是两套受众,不该混为一谈——这不是不一致,是分工。
③ 信号信道
chan bool→chan struct{}Engine.flushCh、Engine.compactCh、Raft.electionCh、Raft.heartbeatCh的接收端一律case <-ch:丢弃该值——那个bool不携带任何信息,用struct{}才是 Go 的写法。raft.voteCh保持chan bool:它真的在传值(voteGranted := <-voteCh)。差点连它一起改,查了接收端才发现。④ 收敛导出面积
以下字段包外零引用,改为包内私有:
Engine.FlushChan(同时与compactCh命名对齐为flushCh)、MsgHandle.TaskQueue/WorkerPoolSize、Server.ExitCh/IPVersion。Server.IP/Port/Name保持导出——集成测试确实在外部设置它们。过程记录
批量改名时正则把
config.G.WorkerPoolSize也改掉了——同名但不同物(那是对外可见的配置字段,改了会破坏配置文件),编译器抓到后已改回。验证
go build ./...(含-tags pprof)、go vet ./...、go test -race ./...、gofmt全绿;scripts/bench.sh实跑通过。🤖 Generated with Claude Code