feat(core): 初始化基础框架并完善接入文档
Verify / verify (push) Canceled after 0s

抽取 Gin、配置、日志、数据库、Redis 与出站 HTTP 基础能力。
新增统一接入指南,将能力清单和相对链接检查纳入 make verify。
对齐远端 module 路径,修正 Redis 读写超时特殊值映射。

验证:make verify、make race-check 均通过。
This commit is contained in:
zhangdeman committed 2026-11-26 19:50:52 -08:00
commit b4c3ac622c
55 files changed
+5862

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
package logger
import (
"fmt"
"os"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
const (
// CodeOutputConfig 表示本地输出缺少必要配置。
CodeOutputConfig = 890001
// CodeOutputDuplicate 表示重复初始化活动日志。
CodeOutputDuplicate = 890002
// CodeOutputDirectory 表示日志目录创建失败。
CodeOutputDirectory = 890003
// CodeOutputWriter 表示轮转输出创建失败。
CodeOutputWriter = 890004
// CodeOutputClose 表示轮转文件关闭失败。
CodeOutputClose = 890005
)
// OutputError 保存日志基础设施错误,避免日志初始化依赖业务错误记录器。
type OutputError struct {
code int `dc:"内部稳定场景码"`
message string `dc:"安全英文错误摘要"`
cause error `dc:"不对外公开的原始原因链"`
}
// Error 返回安全场景摘要。
// 返回:当前日志输出操作的错误描述。
func (e *OutputError) Error() string { return e.message }
// Code 返回内部场景码。
// 返回:仅供内部诊断的数字编码。
func (e *OutputError) Code() int { return e.code }
// Unwrap 保留底层原因供 errors.Is、errors.As 检查。
// 返回:原始错误,没有底层原因时为 nil。
func (e *OutputError) Unwrap() error { return e.cause }
// outputFailure 在输出创建或关闭源头记录一次安全诊断。
// 入参:code 为具名场景码,message 为安全英文摘要,cause 为底层原因。
// 返回:带可追溯原因链的内部错误。
func outputFailure(code int, message string, cause error) error {
var (
result = &OutputError{
code: code,
message: message,
cause: cause,
}
)
// 初始化可能尚无可用文件,直接输出到标准错误,禁止借用全局 Zap 或远端通道。
var (
diagnostic = zap.New(zapcore.NewCore(zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()), zapcore.Lock(os.Stderr), zapcore.ErrorLevel))
)
diagnostic.Error(message, zap.Int("code", code), zap.String("cause_type", fmt.Sprintf("%T", cause)))
return result
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.