core

package
v1.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2023 License: MulanPSL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 应用日志名称
	AppLogName = "app"

	// 运行环境
	DevEnv = "debug"
	ProEnv = "release"
)
View Source
const (
	// 链路追踪
	CTX_TRACE    = "trace"
	CTX_RESPONSE = "response"

	// 日志相关
	TRACE_ID = "trace_id"
	SPAN_ID  = "span_id"

	// 验证器 翻译器
	CTX_VALIDATOR_KEY  = "CtxValidatorKey"
	CTX_TRANSLATOR_KEY = "CtxTranslatorKey"
)

链路追踪相关 Context 环境变量

Variables

View Source
var FixZone = time.FixedZone("CST", 8*3600) //替换上海时区

有些电脑上面使用time.LoadLocation会失败,因为缺少一个文件,可以使用下面的方法替代

View Source
var LocalIP = net.ParseIP("127.0.0.1")
View Source
var RunEnv string // 运行环境
View Source
var SignalNotifyIsRuning = false
View Source
var TimeLocation *time.Location
View Source
var WorkDir string // 工作目录

Functions

func GenSpanId

func GenSpanId() string

生成 spanId

func GenTraceId

func GenTraceId() (traceId string)

获取 traceId

func GetCptConfig

func GetCptConfig(name string, conf interface{}) error

获取 组件配置 并 赋值到 conf 中

func LoadCpt

func LoadCpt(cpt Cpt)

加载单个组件

func LoadCpts

func LoadCpts(instances ...Cpt)

加载多个组件

func LoadGlobalConfigFile

func LoadGlobalConfigFile(path string) error

加载配置文件

func SignalBindFunHandler

func SignalBindFunHandler(handler func(sig os.Signal), signals ...os.Signal)

绑定处理信号的函数

func SignalNotify

func SignalNotify()

系统消息推送

Types

type Cpt

type Cpt interface {
	GetName() string
	Run() error
}

type Trace

type Trace struct {
	TraceId     string
	SpanId      string
	Caller      string
	SrcMethod   string
	HintCode    int64
	HintContent string
}

type TraceContext

type TraceContext struct {
	Trace
	CSpanId string
}

func NewTrace

func NewTrace() *TraceContext

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL