Documentation
¶
Overview ¶
Package context provides a mechanism for transparently tracking contextual state associated to the current goroutine and even across goroutines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface {
// Enter enters a new level on this Context stack.
Enter() Context
// Go starts the given function on a new goroutine.
Go(fn func())
// Exit exits the current level on this Context stack.
Exit()
// Put puts a key->value pair into the current level of the context stack.
Put(key string, value interface{}) Context
// PutIfAbsent puts the given key->value pair into the current level of the
// context stack if and only if that key is defined nowhere within the context
// stack (including parent contexts).
PutIfAbsent(key string, value interface{}) Context
// PutDynamic puts a key->value pair into the current level of the context stack
// where the value is generated by a function that gets evaluated at every Read.
PutDynamic(key string, valueFN func() interface{}) Context
// Fill fills the given map with data from this Context
Fill(m Map)
// AsMap returns a map containing all values from the supplied obj if it is a
// Contextual, plus any addition values from along the stack, plus globals if
// so specified.
AsMap(obj interface{}, includeGlobals bool) Map
}
Context is a context containing key->value pairs
type Contextual ¶
type Contextual interface {
// Fill fills the given Map with all of this Contextual's context
Fill(m Map)
}
Contextual is an interface for anything that maintains its own context.
type Manager ¶
type Manager interface {
// Enter enters a new level on the current Context stack, creating a new Context
// if necessary.
Enter() Context
// Go starts the given function on a new goroutine but sharing the context of
// the current goroutine (if it has one).
Go(func())
// PutGlobal puts the given key->value pair into the globalc context.
PutGlobal(key string, value interface{})
// PutGlobalDynamic puts a key->value pair into the global context wwhere the value is
// generated by a function that gets evaluated at every Read.
PutGlobalDynamic(key string, valueFN func() interface{})
// AsMap returns a map containing all values from the supplied obj if it is a
// Contextual, plus any addition values from along the stack, plus globals if so
// specified.
AsMap(obj interface{}, includeGlobals bool) Map
}
Manager provides the ability to create and access Contexts.
Click to show internal directories.
Click to hide internal directories.
