Documentation ¶
Index ¶
- Constants
- func Bool(ctx context.Context, key string) bool
- func Int64(ctx context.Context, key string) int64
- func IsIncomingKey(key string) (ok bool)
- func IsOutgoingKey(key string) bool
- func NewContext(ctx context.Context, md MD) context.Context
- func Range(ctx context.Context, rangeFunc func(key string, value interface{}), ...)
- func String(ctx context.Context, key string) string
- func Value(ctx context.Context, key string) interface{}
- func WithContext(c context.Context) context.Context
- type MD
Constants ¶
const ( // Network RemoteIP = "remote_ip" RemotePort = "remote_port" ServerAddr = "server_addr" ClientAddr = "client_addr" // Router Cluster = "cluster" Color = "color" // Trace Trace = "trace" Caller = "caller" // Timeout Timeout = "timeout" // Dispatch CPUUsage = "cpu_usage" Errors = "errors" Requests = "requests" // Mirror Mirror = "mirror" // Mid 外网账户用户id Mid = "mid" // NOTE: !!!业务可重新修改key名!!! // Username LDAP平台的username Username = "username" // Device 客户端信息 Device = "device" // Criticality 重要性 Criticality = "criticality" )
metadata common key
Variables ¶
This section is empty.
Functions ¶
func IsIncomingKey ¶
IsIncomingKey represent this key should extract from rpc metadata.
func IsOutgoingKey ¶
IsOutgoingKey represent this key should propagate by rpc.
func NewContext ¶
NewContext creates a new context with md attached.
func Range ¶
func Range(ctx context.Context, rangeFunc func(key string, value interface{}), filterFunc ...func(key string) bool)
Range range value from metadata in context filtered by filterFunc.
Types ¶
type MD ¶
type MD map[string]interface{}
MD is a mapping from metadata keys to values.
func FromContext ¶
FromContext returns the incoming metadata in ctx if it exists. The returned MD should not be modified. Writing to it may cause races. Modification should be made to copies of the returned MD.
func Join ¶
Join joins any number of mds into a single MD. The order of values for each key is determined by the order in which the mds containing those values are presented to Join.