context

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 GetCorrelationID

func GetCorrelationID(ctx stdcontext.Context) string

GetCorrelationID returns the correlation if there is one

func New

func New(opts ...Option) *context

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

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{}
}

Context that matches std context

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