Files
AskaEth eb1828ee7a
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled
docs(comments): 注释中文化 · internal/runtime/orchestration(29 文件,纯替换)
- 只翻注释/文档字符串:剥离注释后代码行逐字节不变(机械校验只剩允许的行尾注释形态)
- 裁决编号与 design 节号(02.4.3 / 11.4.2 / design/05 §9 等)逐字保留
- 复核:go build 绿;orchestration 及其子包(audit/comm)测试绿;gofmt 干净
2026-10-04 13:30:04 +08:00

32 lines
802 B
Go

package orchestration
import (
"crypto/rand"
"encoding/hex"
"io"
"log/slog"
"git.yeij.top/AskaEth/Cyrene_v2/internal/logger"
)
// sourcedLog 返回标注了来源 "orchestration" 的基础 logger,并把 nil logger
// 换成丢弃式 logger,使调度器总能记录日志。
func sourcedLog(l *slog.Logger) *slog.Logger {
if l == nil {
l = slog.New(slog.NewTextHandler(io.Discard, nil))
}
return logger.WithSource(l, "orchestration")
}
// prefixBytes 是构建子代理 id 前缀所用的随机字节数。
const prefixBytes = 4
// randPrefix 返回子代理 id 的短随机前缀;系统熵源不可用时回退为 "sub"。
func randPrefix() string {
var b [prefixBytes]byte
if _, err := rand.Read(b[:]); err != nil {
return "sub"
}
return "sub-" + hex.EncodeToString(b[:])
}