metadata

package
v3.3.14 Latest Latest
Warning

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

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

Documentation

Overview

Package metadata is a way of defining message headers

Package metadata is a way of defining message headers

Index

Constants

This section is empty.

Variables

View Source
var (
	// HeaderPrefix for all headers passed
	HeaderPrefix = "Micro-"
)

Functions

func AppendIncomingContext added in v3.2.15

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

AppendIncomingContext apends new md to context

func AppendOutgoingContext added in v3.2.15

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

AppendOutgoingContext apends new md to context

func NewContext deprecated

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

NewContext creates a new context with the given metadata

Deprecated: use NewIncomingContext or NewOutgoingContext

func NewIncomingContext added in v3.2.9

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

NewIncomingContext creates a new context with incoming metadata attached

func NewOutgoingContext added in v3.2.9

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

NewOutgoingContext creates a new context with outcoming metadata attached

func SetIncomingContext added in v3.2.9

func SetIncomingContext(ctx context.Context, md Metadata) bool

SetIncomingContext modify incoming context with given metadata

func SetOutgoingContext added in v3.2.9

func SetOutgoingContext(ctx context.Context, md Metadata) bool

SetOutgoingContext modify outgoing context with given metadata

Types

type Iterator added in v3.1.4

type Iterator struct {
	// contains filtered or unexported fields
}

Iterator used to iterate over metadata with order

func (*Iterator) Next added in v3.1.4

func (iter *Iterator) Next(k, v *string) bool

Next advance iterator to next element

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 Copy

func Copy(md Metadata) Metadata

Copy makes a copy of the metadata

func FromContext deprecated

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

FromContext returns metadata from the given context returned metadata shoud not be modified or race condition happens

Deprecated: use FromIncomingContext or FromOutgoingContext

func FromIncomingContext added in v3.2.9

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

FromIncomingContext returns metadata from incoming ctx returned metadata shoud not be modified or race condition happens

func FromOutgoingContext added in v3.2.9

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

FromOutgoingContext returns metadata from outgoing ctx returned metadata shoud not be modified or race condition happens

func Merge added in v3.1.6

func Merge(omd Metadata, mmd Metadata, overwrite bool) Metadata

Merge merges metadata to existing metadata, overwriting if specified

func New

func New(size int) Metadata

New return new sized metadata

func Pairs added in v3.2.15

func Pairs(kv ...string) (Metadata, bool)

Pairs from which metadata created

func (Metadata) Del

func (md Metadata) Del(key string)

Del is used to remove value from metadata

func (Metadata) Get

func (md Metadata) Get(key string) (string, bool)

Get returns value from metadata by key

func (Metadata) Iterator added in v3.1.4

func (md Metadata) Iterator() *Iterator

Iterator returns the itarator for metadata in sorted order

func (Metadata) Set

func (md Metadata) Set(key, val string)

Set is used to store value in metadata

Jump to

Keyboard shortcuts

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