bl

package
v0.0.0-...-132f7fb Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidatorKey        = "ValidatorKey"
	TranslatorKey       = "TranslatorKey"
	AdminSessionInfoKey = "AdminSessionInfoKey"

	LoadTypeHTTP = 0
	LoadTypeTCP  = 1
	LoadTypeGRPC = 2

	HTTPRuleTypePrefixURL = 0
	HTTPRuleTypeDomain    = 1

	RedisFlowDayKey  = "flow_day_count"
	RedisFlowHourKey = "flow_hour_count"

	FlowTotal         = "flow_total"
	FlowServicePrefix = "flow_service_"
	FlowAppPrefix     = "flow_app_"

	JwtSignKey = "my_sign_key"
	JwtExpires = 60 * 60
)

Variables

View Source
var (
	LoadTypeMap = map[int]string{
		LoadTypeHTTP: "HTTP",
		LoadTypeTCP:  "TCP",
		LoadTypeGRPC: "GRPC",
	}
)

Functions

func Debug

func Debug(arg ...interface{})

func Debugf

func Debugf(format string, arg ...interface{})

func DefaultGetValidParams

func DefaultGetValidParams(c *gin.Context, params interface{}) error

func Error

func Error(arg ...interface{})

func Errorf

func Errorf(format string, arg ...interface{})

func GetLocalIPs

func GetLocalIPs() (ips []net.IP)

获取localIps

func GetTraceId

func GetTraceId() (traceId string)

func GetTranslation

func GetTranslation(c *gin.Context) (ut.Translator, error)

func GetValidator

func GetValidator(c *gin.Context) (*validator.Validate, error)

func Info

func Info(arg ...interface{})

func Infof

func Infof(format string, arg ...interface{})

func NewSpanId

func NewSpanId() string

func ResponseError

func ResponseError(c *gin.Context, code ResponseCode, err error)

func ResponseSuccess

func ResponseSuccess(c *gin.Context, data interface{})

func SetGinTraceContext

func SetGinTraceContext(c *gin.Context, trace *TraceContext) error

func SetTraceContext

func SetTraceContext(ctx context.Context, trace *TraceContext) context.Context

func Warn

func Warn(arg ...interface{})

func Warnf

func Warnf(format string, arg ...interface{})

Types

type Response

type Response struct {
	ErrorCode ResponseCode `json:"errno"`
	ErrorMsg  string       `json:"errmsg"`
	Data      interface{}  `json:"data"`
	TraceId   interface{}  `json:"trace_id"`
	Stack     interface{}  `json:"stack"`
}

type ResponseCode

type ResponseCode int
const (
	SuccessCode ResponseCode = iota
	UndefErrorCode
	ValidErrorCode
	InternalErrorCode

	InvalidRequestErrorCode ResponseCode = 401
	CustomizeCode           ResponseCode = 1000

	GROUPALL_SAVE_FLOWERROR ResponseCode = 2001
)

1000以下为通用码,1000以上为用户自定义码

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 GetGinTraceContext

func GetGinTraceContext(c *gin.Context) *TraceContext

func GetTraceContext

func GetTraceContext(ctx context.Context) *TraceContext

func NewTrace

func NewTrace() *TraceContext

Jump to

Keyboard shortcuts

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