refactor: 合并 ProviderState/ServerState 结构体 (#2)#7
Merged
Conversation
added 5 commits
July 10, 2026 00:22
有 key disable 但没有 key enable 是设计不对称。新增 enable 命令, 与 disable 对称:接收 provider + index 参数,清除 Disabled 标志, 触发热重载。 同时更新 docs/cli-reference.md 文档。 关闭 #81
Go 1.24 引入 log/slog 集成后,log.Logger.output 内部调用 slog.Default().Handler().Handle(),而 slog 默认 handler 又写入 log.Writer(),形成环形依赖。 InitFileHandler 中通过 multiHandler 包裹了 slog.Default().Handler() 作为 stderr handler,导致 slog.Info 触发死锁。 修复:multiHandler 改用 slog.NewTextHandler(os.Stderr, nil) 直接 写 stderr,避免走 log.Writer() 路径。 同时更新 go.mod 的 go 版本声明从 1.23.0 到 1.24.0,准确反映项目 最低兼容版本。
- 删除 ServerState 结构体,字段提升到 ProviderState - 消除 ps.State 间接层,所有调用直接访问 ProviderState - 移除 ServerState.logs 死代码字段 - 新增 NewProviderState 构造函数一步到位 - ActiveHealthCheck 改为接收 ProviderState 参数 - 更新所有引用点和测试 Closes #2
bigmanBass666
marked this pull request as ready for review
July 10, 2026 14:36
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.
变更内容
将
internal/server包中的ServerState和ProviderState两个结构体合并为一个。纯重构,无外部行为变更。具体变更
ServerState结构体(server.go)PersistKeys、LastHealthCheck、SetLastHealthCheck、Metrics方法移到 ProviderStateNewProviderState构造函数一步到位ps.State间接层,所有调用直接访问 ProviderState 字段ActiveHealthCheck签名改为接收*ProviderStateServerState.logs死代码字段文件改动
验收标准
go build ./...通过go test -tags=unit ./...全部通过go vet ./...通过Closes #2