ctx

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 3 Imported by: 2

README

go-ctx

A reusable context meant to be used more a single instance that is passed down a stack of functions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

Context is a reusable context.Context implementation, intended to be used as a singular context passed down through a data structure.

func New

func New() *Context

New returns a newly instantiated Context.

func (*Context) Deadline

func (ctx *Context) Deadline() (deadline time.Time, ok bool)

Deadline implements context.Context .Deadline().

func (*Context) Done

func (ctx *Context) Done() <-chan struct{}

Done implements context.Context .Done().

func (*Context) Err

func (ctx *Context) Err() error

Err implements context.Context .Err().

func (*Context) Reset

func (ctx *Context) Reset()

Reset will cancel and reset the given context.

func (*Context) Value

func (ctx *Context) Value(key interface{}) interface{}

Value implements context.Context .Value().

func (*Context) WithCancel

func (ctx *Context) WithCancel() func()

WithCancel returns a cancel function for this context.

func (*Context) WithDeadline

func (ctx *Context) WithDeadline(deadline time.Time)

WithDeadline updates the context deadline to supplied time, time <= Now() does nothing.

func (*Context) WithTimeout

func (ctx *Context) WithTimeout(timeout time.Duration)

WithTimeout updates the context deadline to now+timeout, time <= Now() does nothing.

func (*Context) WithValue

func (ctx *Context) WithValue(key interface{}, value interface{})

WithValue sets the supplied key-value pair in context data.

Jump to

Keyboard shortcuts

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