metadata

package
v0.0.0-...-279ef49 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToRequestContext

func AppendToRequestContext(ctx context.Context, kv ...string) context.Context

AppendToRequestContext returns a new context with the provided kv merged with any existing metadata in the context.

func MergeToRequestContext

func MergeToRequestContext(ctx context.Context, cmd Metadata) context.Context

MergeToRequestContext merge new metadata into ctx.

func NewRequestContext

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

NewRequestContext creates a new context with request md attached.

Types

type Metadata

type Metadata map[string]string

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 FromRequestContext

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

FromRequestContext returns the request 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) 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 string, 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