context

package
v0.0.0-...-8fbea3d Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Background

func Background() sysctx.Context

Background is a wrapper for sysctx.Background for ease of use (single import).

func TODO

func TODO() sysctx.Context

TODO is a wrapper for sysctx.TODO for ease of use (single import).

func TestContext

func TestContext(t TestingT) sysctx.Context

TestContext returns a new context with the given testing object configured.

func Value

func Value(ctx sysctx.Context, key interface{}) interface{}

Value is a wrapper for sysctx.Value for ease of use (single import).

func WithCancel

func WithCancel(parent sysctx.Context) (sysctx.Context, sysctx.CancelFunc)

WithCancel is a wrapper for sysctx.WithCancel for ease of use (single import).

func WithDeadline

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

WithDeadline is a wrapper for sysctx.WithDeadline for ease of use (single import).

func WithTestingT

func WithTestingT(ctx sysctx.Context, t TestingT) sysctx.Context

WithTestingT returns a context with the given testing object configured.

func WithTimeout

func WithTimeout(parent sysctx.Context, timeout time.Duration) (sysctx.Context, sysctx.CancelFunc)

WithTimeout is a wrapper for sysctx.WithTimeout for ease of use (single import).

func WithValue

func WithValue(parent sysctx.Context, key, val interface{}) sysctx.Context

WithValue is a wrapper for sysctx.WithValue for ease of use (single import).

Types

type Context

type Context = sysctx.Context

type TestingT

type TestingT interface {
	Log(args ...any)
	Cleanup(func())
	TempDir() string
	Setenv(key, value string)

	zaptest.TestingT
}

TestingT is a subset of the API provided by all *testing.T and *testing.B objects. It is also compatible with zaptest.TestingT. This allows us to write tests that use zaptest and our own context package.

func TestingTFromContext

func TestingTFromContext(ctx sysctx.Context) TestingT

TestingTFromContext returns the testing object configured in the given context. If no testing object is configured, it returns nil.

Jump to

Keyboard shortcuts

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