Documentation
¶
Index ¶
- func ExecWithContext[T any, K comparable](ctx context.Context, key K, exeV func(val T))
- func FromContext[T any, K comparable, V any](ctx context.Context, key K, getV func(val T) V) V
- func JoinContext[T any, K comparable](left, right context.Context, key K, copyT func(dstT, srcT T) T) context.Context
- func NewContext[T any, K comparable](key K, newT func() T) context.Context
- func SetContext[T any, K comparable](ctx context.Context, key K, setT func(curT T) T)
- func ValidateContext[T any, K comparable](ctx context.Context, key K) bool
- func WithContext[T any, K comparable](parent context.Context, key K, newT func() T) context.Context
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.
Click to show internal directories.
Click to hide internal directories.