imeta

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithContext

func WithContext(ctx context.Context, md MD) context.Context

WithContext creates a new context with md attached.

Types

type MD

type MD map[string][]string

MD is a mapping from metadata keys to values. Users should use the following two convenience functions New and Pairs to generate MD.

func FromContext

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

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

func Join(mds ...MD) MD

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.

func New

func New(m map[string]string) MD

New creates an MD from a given key-value map.

Only the following ASCII characters are allowed in keys:

  • digits: 0-9
  • uppercase letters: A-Z (normalized to lower)
  • lowercase letters: a-z
  • special characters: -_.

Uppercase letters are automatically converted to lowercase.

Keys beginning with "grpc-" are reserved for grpc-internal use only and may result in errors if set in metadata.

func Pairs

func Pairs(kv ...string) MD

Pairs returns an MD formed by the mapping of key, value ... Pairs panics if len(kv) is odd.

Only the following ASCII characters are allowed in keys:

  • digits: 0-9
  • uppercase letters: A-Z (normalized to lower)
  • lowercase letters: a-z
  • special characters: -_.

Uppercase letters are automatically converted to lowercase.

Keys beginning with "grpc-" are reserved for grpc-internal use only and may result in errors if set in metadata.

func (MD) Append

func (md MD) Append(k string, vals ...string)

Append adds the values to key k, not overwriting what was already stored at that key.

func (MD) Copy

func (md MD) Copy() MD

Copy returns a copy of md.

func (MD) Get

func (md MD) Get(k string) []string

Get obtains the values for a given key.

func (MD) IsShadow

func (md MD) IsShadow() bool

IsShadow MD中是否包含压测标记

func (MD) Len

func (md MD) Len() int

Len returns the number of items in md.

func (MD) Set

func (md MD) Set(k string, vals ...string)

Set sets the value of a given key with a slice of values.

Jump to

Keyboard shortcuts

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