Documentation ¶
Index ¶
Constants ¶
View Source
const ( // EnvProduction 生产环境 EnvProduction = "production" // EnvTesting 测试环境 EnvTesting = "testing" // EnvDevelopment 开发环境 EnvDevelopment = "development" EnvKey = "web:env" )
View Source
const ( TraceKeyTraceID = "trace_id" TraceKeySpanID = "span_id" TraceKeyCspanID = "cspan_id" TraceKeyParentID = "parent_id" TraceKeyMethod = "method" TraceKeyCaller = "caller" TraceKeyTime = "time" )
View Source
const AppKey = "web:app"
View Source
const ConfigKey = "web:config"
View Source
const DistributedKey = "web:distributed"
View Source
const KernelKey = "web:kernel"
View Source
const LogKey = "web:log"
View Source
const TraceKey = "web:trace"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App interface { // Version 当前版本 Version() string // BaseFolder 项目基础目录 BaseFolder() string // ConfigFolder config foler ConfigFolder() string // LogFolder the folder of log LogFolder() string // ProviderFolder the forlder of provider ProviderFolder() string // MiddlewareFolder middleware folder MiddlewareFolder() string // CommandFolder command folder CommandFolder() string // RuntimeFolder RuntimeFolder() string TestFolder() string // AppFolder 定义业务代码所在目录 AppFolder() string // AppID AppID() string // LoadAppConfig LoadAppConfig(map[string]string) }
type Config ¶
type Config interface { // IsExists 检查一个属性是否存在 IsExists(key string) bool Get(key string) any GetBool(key string) bool GetInt(key string) int GetFloat64(key string) float64 GetTime(key string) time.Time GetString(key string) string GetIntSlice(key string) []int GetStringSlice(key string) []string GetStringMap(key string) map[string]any GetStringMapString(key string) map[string]string GetStringMapStringSlice(key string) map[string][]string // Load 加载配置到某个对象 Load(key string, val any) error }
type CtxFielder ¶
CtxFielder 从context获取信息的方法
type Distributed ¶
type Distributed interface { // Select // serviceName 服务名称 // appID 当前AppID // holdTime 分布式选择器hold住的时间 // selectAppId 分布式选择器最终选择的App Select(serviceName string, appID string, holdTime time.Duration) (selectAppID string, err error) }
Distributed 分布式服务
type Log ¶
type Log interface { // Panic 表示会导致整个程序出现崩溃的日志信息 Panic(ctx context.Context, msg string, fields map[string]any) // Fatal 表示会导致当前这个请求出现提前终止的错误信息 Fatal(ctx context.Context, msg string, fields map[string]any) // Error 表示出现错误信息,但是不一定影响后续请求逻辑的错误信息 Error(ctx context.Context, msg string, fields map[string]any) // Warn 表示出现错误信息,但是不一定影响后续请求逻辑的报警信息 Warn(ctx context.Context, msg string, fields map[string]any) // Info 正常的日志信息 Info(ctx context.Context, msg string, fields map[string]any) // Debug 调试状态下打印出来的信息 Debug(ctx context.Context, msg string, fields map[string]any) // Trace Trace(ctx context.Context, msg string, fields map[string]any) // SetLevel SetLevel(level LogLevel) // SetCtxFielder 从context中获取上下文字段field SetCtxFielder(hander CtxFielder) // SetFormatter 设置输出格式 SetFormatter(formatter Formatter) // SetOutput 设置输出格式 SetOutput(out io.Writer) }
type Trace ¶
type Trace interface { // WithTrace register new trace to context WithTrace(context.Context, *TraceContext) context.Context // GetTrace From trace context GetTrace(context.Context) *TraceContext // NewTrace generate a new trace NewTrace() *TraceContext // StartSpan generate cspan for child call StartSpan(*TraceContext) *TraceContext // ToMap 将logger转换为map ToMap(*TraceContext) map[string]string // 通过http ExtractHTTP(*http.Request) *TraceContext // 给http添加trace InjectHTTP(*http.Request, *TraceContext) *http.Request }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.