Documentation ¶
Index ¶
- Variables
- func ExtractMIMIETags(ctx context.Context, key interface{}) (tags textproto.MIMEHeader, has bool)
- func ExtractOrCreateMIMETags(ctx context.Context, key interface{}) (ctx_ context.Context, stags textproto.MIMEHeader)
- func WithMIMETags(ctx context.Context, key interface{}, tags textproto.MIMEHeader) context.Context
- func WithShutdownSignal(parent context.Context, sig ...os.Signal) context.Context
- func WithSignal(parent context.Context, sig ...os.Signal) (ctx context.Context, cancel context.CancelFunc)
- func WithTags(ctx context.Context, key interface{}, tags Tags) context.Context
- type EmptyMapTagsOption
- type Key
- type MapTagsOption
- type MapTagsOptionFunc
- type Tags
Constants ¶
This section is empty.
Variables ¶
var (
// NopTags is a trivial, minimum overhead implementation of Tags for which all operations are no-ops.
NopTags = &nopTags{}
)
Functions ¶
func ExtractMIMIETags ¶ added in v0.0.150
func ExtractMIMIETags(ctx context.Context, key interface{}) (tags textproto.MIMEHeader, has bool)
ExtractMIMIETags returns a pre-existing Tags object in the Context. If the context wasn't set in a tag interceptor, a no-op Tag storage is returned that will *not* be propagated in context.
func ExtractOrCreateMIMETags ¶ added in v0.0.150
func ExtractOrCreateMIMETags(ctx context.Context, key interface{}) ( ctx_ context.Context, stags textproto.MIMEHeader)
ExtractOrCreateMIMETags extracts or create tags from context by key
func WithMIMETags ¶ added in v0.0.150
WithMIMETags create tags from context by key
func WithShutdownSignal ¶ added in v0.0.93
WithShutdownSignal registered for signals. A context.Context is returned. If no signals are provided, incoming os_.ShutdownSignals signals will be relayed. Otherwise, just the provided signals will. which is done on one of these incoming signals. If a second signal is caught, the program is terminated with exit code 1. Only one of Signal should be called, and only can be called once.
func WithSignal ¶ added in v0.0.93
func WithSignal(parent context.Context, sig ...os.Signal) (ctx context.Context, cancel context.CancelFunc)
WithSignal registered for signals. A context.Context is returned. which is done on one of these incoming signals. signals can be stopped by stopSignal, context will never be Done() if stopped. WithSignal returns a copy of the parent context registered for signals. If the parent's context is already done than d, WithSignal(parent, sig...) is semantically equivalent to parent. The returned context's Done channel is closed when one of these incoming signals, when the returned cancel function is called, or when the parent context's Done channel is closed, whichever happens first. Canceling this context releases resources associated with it, so code should call cancel as soon as the operations running in this Context complete. Deprecated: Use signal.NotifyContext instead since go1.16.
Types ¶
type EmptyMapTagsOption ¶
type EmptyMapTagsOption struct{}
EmptyMapTagsOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type MapTagsOption ¶
type MapTagsOption interface {
// contains filtered or unexported methods
}
A MapTagsOption sets options.
func WithMapTagsMimeKey ¶ added in v0.0.150
func WithMapTagsMimeKey() MapTagsOption
WithMapTagsMimeKey represents a MIME-style key mapping
type MapTagsOptionFunc ¶
type MapTagsOptionFunc func(*mapTags)
MapTagsOptionFunc wraps a function that modifies mapTags into an implementation of the MapTagsOption interface.
type Tags ¶
type Tags interface { // Set sets the given key in the metadata tags. Set(key string, value interface{}) // Get gets if the metadata tags got by the given key exists. Get(key string) (interface{}, bool) // Del deletes the values associated with key. Del(key string) // Values returns a map of key to values. // Do not modify the underlying map, please use Set instead. Values() map[string]interface{} }
Tags is the interface used for storing request tags between Context calls. The default implementation is *not* thread safe, and should be handled only in the context of the request.
func ExtractOrCreateTags ¶ added in v0.0.150
func ExtractOrCreateTags(ctx context.Context, key interface{}, options ...MapTagsOption) ( ctx_ context.Context, stags Tags)
ExtractOrCreateTags extracts or create tags from context by key
func ExtractTags ¶
ExtractTags returns a pre-existing Tags object in the Context. If the context wasn't set in a tag interceptor, a no-op Tag storage is returned that will *not* be propagated in context.
func NewMapTags ¶ added in v0.0.150
func NewMapTags(options ...MapTagsOption) Tags