Documentation ¶
Index ¶
- Constants
- func AddUIDFromMDCtx(ctx context.Context) context.Context
- func AppendToClientContext(ctx context.Context, kv ...string) context.Context
- func AppendUIDToClientContext(ctx context.Context, uid string) context.Context
- func CloneToClientContext(src context.Context) (dst context.Context)
- func CloneToServerContext(src context.Context) (dst context.Context)
- func FromCmdContext(ctx context.Context) string
- func FromGateContext(ctx context.Context) (string, bool)
- func FromUIDContext(ctx context.Context) (uid string, ok bool)
- func GetUID(ctx context.Context) string
- func GetUIDFromClientContext(ctx context.Context) string
- func GetUIDFromMDCtx(ctx context.Context) string
- func MergeToClientContext(ctx context.Context, cmd Metadata) context.Context
- func NewClientContext(ctx context.Context, md Metadata) context.Context
- func NewClientUIDContext(ctx context.Context, uid string) context.Context
- func NewServerContext(ctx context.Context, md Metadata) context.Context
- func NewUIDContext(ctx context.Context, uid string) context.Context
- type Metadata
Constants ¶
const ( UIDKey = "x-md-global-uid" CmdKey = "x-md-cmd" GateAddrKey = "x-md-global-gate" //存储gatesrv地址 )
定义一些游戏里面需要使用到的key
Variables ¶
This section is empty.
Functions ¶
func AddUIDFromMDCtx ¶
AddUIDFromMDCtx 如果uidKey结构的ctx中没有uid,就从metadata中提取uid,存储到uidKey中
func AppendToClientContext ¶
AppendToClientContext returns a new context with the provided kv merged with any existing metadata in the context.
func FromCmdContext ¶
func FromUIDContext ¶
FromUIDContext 从uidKey结构里面获取uid
func GetUIDFromClientContext ¶
func GetUIDFromMDCtx ¶
GetUIDFromMDCtx 根据ctx获取metadata,再从metadata里面获取uid
func MergeToClientContext ¶
MergeToClientContext merge new metadata into ctx.
func NewClientContext ¶
NewClientContext creates a new context with client md attached.
func NewClientUIDContext ¶
func NewServerContext ¶
NewServerContext creates a new context with client md attached.
Types ¶
type Metadata ¶
Metadata is our way of representing request headers internally. They're used at the RPC level and translate back and forth from Transport headers.
func FromClientContext ¶
FromClientContext returns the client metadata in ctx if it exists.
func FromServerContext ¶
FromServerContext returns the server metadata in ctx if it exists.