Documentation ¶
Overview ¶
Package onecontext provides a mechanism to merge multiple existing contexts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCanceled = errors.New("context canceled")
ErrCanceled is the returned when the CancelFunc returned by Merge is called.
Functions ¶
Types ¶
type DetachedContext ¶
type DetachedContext struct {
// contains filtered or unexported fields
}
DetachedContext holds the logic to detach a cancellation signal from a context.
func Detach ¶
func Detach(ctx context.Context) (*DetachedContext, func())
Detach detaches the cancellation signal from a context.
func (*DetachedContext) Deadline ¶
func (c *DetachedContext) Deadline() (time.Time, bool)
Deadline returns a nil deadline.
func (*DetachedContext) Done ¶
func (c *DetachedContext) Done() <-chan struct{}
Done returns a cancellation signal that expires only when the context is canceled from the cancel function returned in Detach.
func (*DetachedContext) Err ¶
func (c *DetachedContext) Err() error
Err returns an error if the context is canceled from the cancel function returned in Detach.
func (*DetachedContext) Value ¶
func (c *DetachedContext) Value(key interface{}) interface{}
Value returns the value associated with the key from the original context.
type OneContext ¶
type OneContext struct {
// contains filtered or unexported fields
}
OneContext is the struct holding the context grouping logic.
func (*OneContext) Deadline ¶
func (o *OneContext) Deadline() (time.Time, bool)
Deadline returns the minimum deadline among all the contexts.
func (*OneContext) Done ¶
func (o *OneContext) Done() <-chan struct{}
Done returns a channel for cancellation.
func (*OneContext) Err ¶
func (o *OneContext) Err() error
Err returns the first error raised by the contexts, otherwise a nil error.
func (*OneContext) Value ¶
func (o *OneContext) Value(key interface{}) interface{}
Value returns the value associated with the key from one of the contexts.
type ResetValuesContext ¶
type ResetValuesContext struct {
// contains filtered or unexported fields
}
ResetValuesContext holds the logic reset the values of a context.
func ResetValues ¶
func ResetValues(ctx context.Context) *ResetValuesContext
ResetValues reset the values of a context.
func (*ResetValuesContext) Deadline ¶
func (c *ResetValuesContext) Deadline() (time.Time, bool)
Deadline returns the original context deadline.
func (*ResetValuesContext) Done ¶
func (c *ResetValuesContext) Done() <-chan struct{}
Done returns the original done channel.
func (*ResetValuesContext) Err ¶
func (c *ResetValuesContext) Err() error
Err returns the original context error.
func (*ResetValuesContext) Value ¶
func (c *ResetValuesContext) Value(_ interface{}) interface{}
Value returns nil regardless of the key.