context

package
v1.2.41 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Canceled         = context.Canceled
	DeadlineExceeded = context.DeadlineExceeded
)

Functions

func AfterFunc

func AfterFunc(ctx Context, f func()) (stop func() bool)

func LocalValue added in v1.2.0

func LocalValue[T any](ctx Context, key []byte) (v T, has bool)

func Release

func Release(ctx context.Context)

func UserValue added in v1.2.0

func UserValue[T any](ctx Context, key []byte) (v T, has bool, err error)

func Value added in v1.2.0

func Value[T any](ctx Context, key any) (v T, has bool)

func WithCancel

func WithCancel(parent Context) (Context, CancelFunc)

func WithDeadline

func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc)

func WithDeadlineCause

func WithDeadlineCause(parent Context, deadline time.Time, cause error) (Context, CancelFunc)

func WithTimeout

func WithTimeout(parent Context, ttl time.Duration) (Context, CancelFunc)

func WithTimeoutCause

func WithTimeoutCause(parent Context, ttl time.Duration, cause error) (Context, CancelFunc)

Types

type CancelFunc

type CancelFunc context.CancelFunc

type Context

type Context interface {
	context.Context
	UserValue(key []byte) any
	SetUserValue(key []byte, val any)
	UserValues(fn func(key []byte, val any))
	LocalValue(key []byte) any
	SetLocalValue(key []byte, val any)
	LocalValues(fn func(key []byte, val any))
}

func Acquire

func Acquire(ctx context.Context) Context

func Fork added in v1.2.34

func Fork(ctx context.Context) Context

func TODO

func TODO() Context

func WithValue

func WithValue(parent context.Context, key any, val any) Context

func WithoutCancel

func WithoutCancel(parent Context) Context

func Wrap

func Wrap(ctx context.Context) Context

type Entries

type Entries []Entry

func (*Entries) Foreach

func (entries *Entries) Foreach(fn func(key []byte, value any))

func (*Entries) Get

func (entries *Entries) Get(key []byte) (val any)

func (*Entries) Len

func (entries *Entries) Len() int

func (*Entries) Remove

func (entries *Entries) Remove(key []byte)

func (*Entries) Reset

func (entries *Entries) Reset()

func (*Entries) Set

func (entries *Entries) Set(key []byte, val any)

type Entry

type Entry struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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