scontext

package
v1.4.13 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyTraceID = "traceID"

	ContextKeyHead        = "Head"
	ContextKeyHeadUid     = "uid"
	ContextKeyHeadSource  = "source"
	ContextKeyHeadIp      = "ip"
	ContextKeyHeadRegion  = "region"
	ContextKeyHeadDt      = "dt"
	ContextKeyHeadUnionId = "unionid"

	ContextKeyControl = "Control"
)

由于请求的上下文信息的 thrift 定义在 util 项目中,本模块主要为了避免循环依赖

View Source
const DefaultGroup = ""

Variables

View Source
var ErrInvalidContext = errors.New("invalid context")

Functions

func GetControlCallerMethod

func GetControlCallerMethod(ctx context.Context) (method string, ok bool)

func GetControlCallerServerId

func GetControlCallerServerId(ctx context.Context) (serverId string, ok bool)

func GetControlCallerServerName

func GetControlCallerServerName(ctx context.Context) (serverName string, ok bool)

func GetControlRouteGroup

func GetControlRouteGroup(ctx context.Context) (group string, ok bool)

func GetControlRouteGroupWithDefault

func GetControlRouteGroupWithDefault(ctx context.Context, dv string) string

func GetDt

func GetDt(ctx context.Context) (dt int32, ok bool)

func GetIp

func GetIp(ctx context.Context) (ip string, ok bool)

func GetRegion

func GetRegion(ctx context.Context) (region string, ok bool)

func GetSource

func GetSource(ctx context.Context) (source int32, ok bool)

func GetUid

func GetUid(ctx context.Context) (uid int64, ok bool)

func GetUnionId

func GetUnionId(ctx context.Context) (unionId string, ok bool)

func SetControlCallerMethod

func SetControlCallerMethod(ctx context.Context, method string) (context.Context, error)

func SetControlCallerServerId

func SetControlCallerServerId(ctx context.Context, serverId string) (context.Context, error)

func SetControlCallerServerName

func SetControlCallerServerName(ctx context.Context, serverName string) (context.Context, error)

func SetControlRouteGroup

func SetControlRouteGroup(ctx context.Context, group string) (context.Context, error)

Types

type ContextControlCaller

type ContextControlCaller interface {
	GetControlCallerServerName() (string, bool)
	SetControlCallerServerName(string) error
	GetControlCallerServerId() (string, bool)
	SetControlCallerServerId(string) error
	GetControlCallerMethod() (string, bool)
	SetControlCallerMethod(string) error
}

type ContextControlRouter

type ContextControlRouter interface {
	GetControlRouteGroup() (string, bool)
	SetControlRouteGroup(string) error
}

type ContextHeader

type ContextHeader interface {
	ToKV() map[string]interface{}
}

Jump to

Keyboard shortcuts

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