metadata

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package metadata provides support for the propagation of metadata information from a component method caller to the callee. The metadata is propagated to the callee even if the caller and callee are not colocated in the same process.

The metadata is a map from string to string stored in context.Context. The map can be added to a context by calling NewContext.

Example:

To attach metadata with key "foo" and value "bar" to the context:

ctx := context.Background()
ctx = metadata.NewContext(ctx, map[string]string{"foo": "bar"})

To read the metadata value associated with a key "foo" in the context:

meta, found := metadata.FromContext(ctx)
if found {
	  value := meta["foo"]
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) (map[string]string, bool)

FromContext returns the metadata value stored in ctx, if any.

func NewContext

func NewContext(ctx context.Context, meta map[string]string) context.Context

NewContext returns a new context that carries metadata meta.

Types

This section is empty.

Jump to

Keyboard shortcuts

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