metadata

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package metadata provides a canonical map[string]string carried across RPC and message boundaries, plus helpers to attach and read it from a context. It complements pkg/transport's protocol-agnostic Header view: Header adapts http.Header / grpc metadata.MD, while Metadata is the normalized key/value payload used by broker messages and service-to-service propagation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ctx context.Context, key string) context.Context

Delete returns ctx with a single metadata key removed.

func Get

func Get(ctx context.Context, key string) (string, bool)

Get returns the value for key in ctx's metadata.

func MergeContext

func MergeContext(ctx context.Context, patch Metadata, overwrite bool) context.Context

MergeContext returns ctx with patch merged into its existing metadata. When overwrite is false, existing values win over patch.

func NewContext

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

NewContext returns ctx carrying md.

func Set

func Set(ctx context.Context, key, val string) context.Context

Set returns ctx with a single metadata key set.

Types

type Metadata

type Metadata map[string]string

Metadata is a normalized set of string key/value pairs.

func Copy

func Copy(md Metadata) Metadata

Copy returns a shallow copy of md.

func FromContext

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

FromContext returns the metadata attached to ctx.

func (Metadata) Delete

func (md Metadata) Delete(key string)

Delete removes key.

func (Metadata) Get

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

Get returns the value for key and whether it was present.

func (Metadata) Set

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

Set stores val under key.

Jump to

Keyboard shortcuts

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