generic

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecWithContext

func ExecWithContext[T any, K comparable](
	ctx context.Context,
	key K,
	exeV func(val T))

ExecWithContext executes the provided function while holding the lock on the context.

func FromContext

func FromContext[T any, K comparable, V any](
	ctx context.Context,
	key K,
	getV func(val T) V) V

FromContext returns the data from the context.

func JoinContext

func JoinContext[T any, K comparable](
	left, right context.Context,
	key K,
	copyT func(dstT, srcT T) T) context.Context

JoinContext returns a new context that contains a reference the data at the specified key. This function panics if the provided context does not contain the data. This function is thread-safe.

func NewContext

func NewContext[T any, K comparable](key K, newT func() T) context.Context

NewContext returns a new context with the data in the specified key.

func SetContext

func SetContext[T any, K comparable](
	ctx context.Context,
	key K,
	setT func(curT T) T)

SetContext sets the data in the context.

func ValidateContext

func ValidateContext[T any, K comparable](ctx context.Context, key K) bool

ValidateContext returns true if the provided context contains the data at the specified key.

func WithContext

func WithContext[T any, K comparable](
	parent context.Context,
	key K,
	newT func() T) context.Context

WithContext returns a new context with the data in the specified key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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