metadata

package
v0.0.0-...-ead621a Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(m MD) ([]byte, error)

func NewIncomingContext

func NewIncomingContext(father context.Context, m map[string]any) context.Context

NewIncomingContext creates a new context with incoming md attached. Note: md must not be modified after calling this function. Note: md 不能在调用此函数后被修改

func NewOutContext

func NewOutContext(father context.Context, m map[string]any) context.Context

NewOutContext creates a new context with outgoing md attached. Note: md must not be modified after calling this function. Note: md 不能在调用此函数后被修改

func Unmarshal

func Unmarshal(data []byte, dst *MD) error

Types

type MD

type MD map[string]any

MD is a mapping from metadata keys to values. MD 是附加传输的上下文信息

func FromIncomingContext

func FromIncomingContext(ctx context.Context) (md MD, ok bool)

func FromOutContext

func FromOutContext(ctx context.Context) (md MD, ok bool)

func New

func New(kvs map[string]any) MD

func (*MD) Get

func (ins *MD) Get(key string) (v any, exist bool)

func (*MD) GetBool

func (ins *MD) GetBool(key string) (bool, bool)

func (*MD) GetFloat32

func (ins *MD) GetFloat32(key string) (float32, bool)

func (*MD) GetFloat64

func (ins *MD) GetFloat64(key string) (float64, bool)

func (*MD) GetInt

func (ins *MD) GetInt(key string) (int, bool)

func (*MD) GetInt8

func (ins *MD) GetInt8(key string) (int8, bool)

func (*MD) GetInt16

func (ins *MD) GetInt16(key string) (int16, bool)

func (*MD) GetInt32

func (ins *MD) GetInt32(key string) (int32, bool)

func (*MD) GetInt64

func (ins *MD) GetInt64(key string) (int64, bool)

func (*MD) GetString

func (ins *MD) GetString(key string) (string, bool)

func (*MD) Set

func (ins *MD) Set(key string, value any)

Jump to

Keyboard shortcuts

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