docs(agent): 统一中文注释并补充部署文档

将代码与测试注释改为中文以符合仓库规范;新增中文部署指南、
示例配置,并完善构建脚本对 VERSION 注入的说明。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
codex
2026-05-19 02:30:49 +00:00
parent 89d5e27874
commit 877e4cf41d
28 changed files with 608 additions and 226 deletions

View File

@@ -7,24 +7,24 @@ import (
"mfd-monitor-agent/internal/status"
)
// Provider supplies the latest cached HostStatus to HTTP handlers.
// Provider 向 HTTP 处理器提供最新缓存的 HostStatus。
type Provider interface {
// Get returns the latest snapshot and whether a snapshot is ready.
// Get 返回最新快照及快照是否已就绪。
Get() (status.HostStatus, bool)
}
// StaticProvider is a test provider with a fixed snapshot response.
// StaticProvider 是用于测试的固定快照提供者。
type StaticProvider struct {
Snapshot status.HostStatus
OK bool
}
// Get returns the configured static snapshot and readiness flag.
// Get 返回配置的静态快照与就绪标志。
func (p StaticProvider) Get() (status.HostStatus, bool) {
return p.Snapshot, p.OK
}
// New creates the HTTP API handler for health and status endpoints.
// New 创建提供 health 与 status 端点的 HTTP API 处理器。
func New(provider Provider) http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
@@ -61,7 +61,7 @@ func New(provider Provider) http.Handler {
return mux
}
// writeJSON serializes value as JSON with a response status code.
// writeJSON 以给定状态码将 value 序列化为 JSON 响应。
func writeJSON(w http.ResponseWriter, code int, value any) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)