metadata

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeContext

func MergeContext(ctx context.Context, patchMd Metadata, overwrite bool) context.Context

MergeContext merge new metadata into ctx. if patchMd key exists, but value is empty, means delete it. overwrite flag means if key exist, it will be overwritten.

func NewContext

func NewContext(ctx context.Context, md Metadata) context.Context

NewContext creates a new context with client md attached.

Types

type Metadata

type Metadata map[string]string

Metadata is a map[string]string of key/value pairs.

func FromContext

func FromContext(ctx context.Context) (Metadata, bool)

FromContext returns the metadata in ctx if it exists.

func New

func New(mds ...map[string]string) Metadata

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

func (Metadata) Clone

func (m Metadata) Clone() Metadata

Clone returns a deep copy of Metadata

func (Metadata) Delete

func (m Metadata) Delete(key string)

Set stores the key-value pair.

func (Metadata) Exist

func (m Metadata) Exist(key string) bool

func (Metadata) Get

func (m Metadata) Get(key string) string

Get returns the value associated with the passed key.

func (Metadata) Range

func (m Metadata) Range(f func(k, v string) bool)

Range iterate over element in metadata.

func (Metadata) Set

func (m Metadata) Set(key, value string)

Set stores the key-value pair.

Jump to

Keyboard shortcuts

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