metadata

package
v4.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 3 Imported by: 7

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"
	// HeaderXRequestID specifies request id
	HeaderXRequestID = "X-Request-Id"
)

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

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

NewContext creates a new context with the given metadata

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

Types

type Metadata

type Metadata map[string][]string

Metadata is our way of representing request headers internally.

func Copy

func Copy(md Metadata, exclude ...string) Metadata

Copy makes a copy of the metadata

func FromContext

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

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

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

Pairs from which metadata created

func (Metadata) Append added in v4.0.18

func (md Metadata) Append(k string, v ...string)

Append is used to append value in metadata

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) 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