baggage

package
v2.12.0-dev.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(ctx context.Context) map[string]string

All returns a **copy** of all baggage items in the context,

func Clear

func Clear(ctx context.Context) context.Context

Clear completely removes all baggage items from the context.

func Get

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

Get retrieves the value associated with a baggage key. If the key isn't found, it returns an empty string.

func Remove

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

Remove removes the specified key from the baggage (if present).

func Set

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

Set sets or updates a single baggage key/value pair in the context. If the key already exists, this function overwrites the existing value.

Set clones the entire baggage map on every call. Use it for one-off, standalone updates. If you're writing more than one key as part of the same logical update (e.g. reconciling baggage from another source), call SetAll once instead of Set in a loop — looping Set reclones the whole map on every iteration, which is O(N) clones for N keys instead of one.

func SetAll

func SetAll(ctx context.Context, values map[string]string) context.Context

SetAll merges multiple key/value pairs into the baggage in a single context write. Equivalent to calling Set once per entry in values, but only clones the baggage map once instead of once per key. Prefer this over a Set loop whenever the key/value pairs are already available together, e.g. when reconciling baggage extracted from another source (headers, another baggage format, etc.) rather than a single standalone update.

Types

This section is empty.

Jump to

Keyboard shortcuts

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