metadata

package
v3.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 3 Imported by: 26

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 (
	// HeaderTopic is the header name that contains topic name
	HeaderTopic = "Micro-Topic"
	// HeaderContentType specifies content type of message
	HeaderContentType = "Content-Type"
	// HeaderEndpoint specifies endpoint in service
	HeaderEndpoint = "Micro-Endpoint"
	// HeaderService specifies service
	HeaderService = "Micro-Service"
	// HeaderTimeout specifies timeout of operation
	HeaderTimeout = "Micro-Timeout"
	// HeaderAuthorization specifies Authorization header
	HeaderAuthorization = "Authorization"
)

Functions

func AppendIncomingContext

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

AppendIncomingContext apends new md to context

func AppendOutgoingContext

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

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

NewIncomingContext creates a new context with incoming metadata attached

func NewOutgoingContext

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

NewOutgoingContext creates a new context with outcoming metadata attached

func SetIncomingContext

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

SetIncomingContext modify incoming context with given metadata

func SetOutgoingContext

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

SetOutgoingContext modify outgoing context with given metadata

Types

type Iterator

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

Iterator used to iterate over metadata with order

func (*Iterator) Next

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

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

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

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

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

Pairs from which metadata created

func (Metadata) Del

func (md Metadata) Del(keys ...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

func (md Metadata) Iterator() *Iterator

Iterator returns the itarator for metadata in sorted order

func (Metadata) Set

func (md Metadata) Set(kv ...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