context

package
v0.14.5 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCorrelationID

func GetCorrelationID(ctx stdcontext.Context) string

GetCorrelationID returns the correlation if there is one

Types

type CancelFunc

type CancelFunc func()

A CancelFunc tells an operation to abandon its work

type Context

type Context interface {
	Cancel()
	Deadline() (deadline time.Time, ok bool)
	Done() <-chan struct{}
	Err() error
	Value(key interface{}) interface{}
	Arguments() map[string]interface{}
	Method() string
	CorrelationID() string
}

Context that matches std context

func Background

func Background() Context

Background context wrapper

func FromContext

func FromContext(ctx stdcontext.Context) Context

FromContext returns a new context from a parent

func New

func New(opts ...Option) Context

New constructs a new *context from a parent Context and Options

func TODO added in v0.11.0

func TODO() Context

TODO returns a non-nil, empty Context. Code should use context.TODO when it's unclear which Context to use or it is not yet available.

type Option

type Option func(*context)

Option allows configuring the context

func WithArgument

func WithArgument(key string, value interface{}) Option

WithArgument sets a Context argument

func WithArguments

func WithArguments(args map[string]interface{}) Option

WithArguments sets the Context arguments

func WithCancel

func WithCancel() Option

WithCancel makes the context cancelable

func WithCorrelationID

func WithCorrelationID(cID string) Option

WithCorrelationID sets the CorrelationID

func WithMethod

func WithMethod(method string) Option

WithMethod sets the Context method name

func WithParent

func WithParent(parent stdcontext.Context) Option

WithParent sets the context's parent context

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets a Context timeout

Jump to

Keyboard shortcuts

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