Versions in this module Expand all Collapse all v0 v0.19.4 Nov 1, 2026 Changes in this version + var ErrKeyNotFound = errors.New("key not found in context") + var ErrMarshalFailed = errors.New("failed to marshal value") + var ErrUnmarshalFailed = errors.New("failed to unmarshal value") + func GetOrDefault[T any](ctx context.Context, key any, defaultValue T) T + func GetValue[T any](ctx context.Context, key any) T + func Get[T any](c *Context, key interface{}) T + func IsContext(ctx context.Context) bool + func MustGetWithMessage[T any](ctx context.Context, key any, message string) T + func MustGet[T any](ctx context.Context, key any) T + func NewDetachedTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc) + func OrBackground(ctx context.Context) context.Context + func OrWithoutCancel(ctx context.Context) context.Context + func WithDeadlineDecorators(deadline time.Time, decorators ...func(context.Context) context.Context) (context.Context, context.CancelFunc) + func WithDetachedTimeout(parent context.Context, timeout time.Duration, fn func(context.Context) error) error + func WithTimeout(timeout time.Duration, fn func(context.Context) error) error + func WithTimeoutDecorators(timeout time.Duration, decorators ...func(context.Context) context.Context) (context.Context, context.CancelFunc) + func WithTimeoutFrom(parent context.Context, timeout time.Duration, fn func(context.Context) error) error + func WithTimeoutOrBackground(parent context.Context, timeout time.Duration, fn func(context.Context) error) error + func WithTimeoutValue[T any](timeout time.Duration, fn func(context.Context) (T, error)) (T, error) + func WithValue(ctx context.Context, key, value interface{}) context.Context + type Context struct + func MergeContext(ctxs ...context.Context) *Context + func NewContext() *Context + func NewContextWithTimeout(timeout time.Duration) *Context + func NewContextWithValue(key, val interface{}) *Context + func (c *Context) Cancel() + func (c *Context) Clone() *Context + func (c *Context) Deadline() (deadline time.Time, ok bool) + func (c *Context) GetAllMetadata() map[string]string + func (c *Context) GetBool(key interface{}) bool + func (c *Context) GetDuration(key interface{}) time.Duration + func (c *Context) GetFloat32(key interface{}) float32 + func (c *Context) GetFloat64(key interface{}) float64 + func (c *Context) GetInt(key interface{}) int + func (c *Context) GetInt16(key interface{}) int16 + func (c *Context) GetInt32(key interface{}) int32 + func (c *Context) GetInt64(key interface{}) int64 + func (c *Context) GetInt8(key interface{}) int8 + func (c *Context) GetIntSlice(key interface{}) []int + func (c *Context) GetMap(key interface{}) map[string]interface{} + func (c *Context) GetMetadata(key string) string + func (c *Context) GetRune(key interface{}) rune + func (c *Context) GetString(key interface{}) string + func (c *Context) GetStringSlice(key interface{}) []string + func (c *Context) GetTime(key interface{}) time.Time + func (c *Context) GetUint(key interface{}) uint + func (c *Context) GetUint16(key interface{}) uint16 + func (c *Context) GetUint32(key interface{}) uint32 + func (c *Context) GetUint64(key interface{}) uint64 + func (c *Context) GetUint8(key interface{}) uint8 + func (c *Context) IsExpired() bool + func (c *Context) MustValue(key interface{}) interface{} + func (c *Context) Range(f func(key, value interface{}) bool) + func (c *Context) Remove(key interface{}) *Context + func (c *Context) SafeGetStringSlice(key interface{}) []string + func (c *Context) SetBatch(kvs map[interface{}]interface{}) *Context + func (c *Context) SetDeadline(timeout time.Duration) *Context + func (c *Context) SetMetadataBatch(kvs map[string]string) *Context + func (c *Context) String() string + func (c *Context) Value(key interface{}) interface{} + func (c *Context) Values() map[interface{}]interface{} + func (c *Context) WithByteSlice(key interface{}, value []byte) *Context + func (c *Context) WithCancel() *Context + func (c *Context) WithDeadline(deadline time.Time) *Context + func (c *Context) WithMetadata(key, value string) *Context + func (c *Context) WithParent(parent context.Context) *Context + func (c *Context) WithPool(pool *syncx.LimitedPool) *Context + func (c *Context) WithTimeout(timeout time.Duration) *Context + func (c *Context) WithValue(key, value interface{}) *Context + type Marshaler interface + Marshal func(v any) (string, error) + Unmarshal func(data string, v any) error + type MetadataAdapter interface + Append func(ctx context.Context, key, value string) context.Context + Get func(ctx context.Context, key string) (string, bool) + Set func(ctx context.Context, key, value string) context.Context + type MetadataManager struct + func NewMetadataManager(adapter MetadataAdapter, marshaler Marshaler) *MetadataManager + func (m *MetadataManager) Append(ctx context.Context, key string, value any) (context.Context, error) + func (m *MetadataManager) Get(ctx context.Context, key string, result any) error + func (m *MetadataManager) GetOrDefault(ctx context.Context, key string, defaultValue any) any + func (m *MetadataManager) Set(ctx context.Context, key string, value any) (context.Context, error)