ctx

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCanceled = errors.New("context canceled")

ErrCanceled is the returned when the CancelFunc returned by Merge is called.

Functions

func Merge

Merge merges the given contexts into a single context that will be done when any of the given contexts is done.

Types

type Key

type Key[Value any] struct {
	// contains filtered or unexported fields
}

Key ...

func New

func New[Value any](name string, v Value) Key[Value]

New ...

func (Key[Value]) Has

func (k Key[Value]) Has(ctx context.Context) (ok bool)

Has ...

func (Key[Value]) String

func (k Key[Value]) String() string

String ...

func (Key[Value]) Value

func (k Key[Value]) Value(ctx context.Context) (v Value)

Value ...

func (Key[Value]) ValueOk

func (k Key[Value]) ValueOk(ctx context.Context) (v Value, ok bool)

ValueOk ...

func (Key[Value]) WithValue

func (k Key[Value]) WithValue(parent context.Context, val Value) context.Context

WithValue ...

type OneContext

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

OneCtx is a context that can be used to wait for one of multiple contexts to be done.

func (*OneContext) Deadline

func (o *OneContext) Deadline() (time.Time, bool)

Deadline returns the minimum deadline among all the contexts.

func (*OneContext) Done

func (o *OneContext) Done() <-chan struct{}

Done returns a channel for cancellation.

func (*OneContext) Err

func (o *OneContext) Err() error

Err returns the first error raised by the contexts, otherwise a nil error.

func (*OneContext) Value

func (o *OneContext) Value(key interface{}) interface{}

Value returns the value associated with the key from one of the contexts.

Jump to

Keyboard shortcuts

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