Documentation
¶
Overview ¶
multicontext package provides tools to aggregate the characteristics of multiple context.Context objects into one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MultiContext ¶
A MultiContext is a struct providing context.Context and aggregating the characteritics of multiple child contexts.
func (MultiContext) Deadline ¶
func (mc MultiContext) Deadline() (deadline time.Time, ok bool)
Deadline returns the time when work done on behalf of this context should be canceled. Deadline returns ok==false when no deadline is set. Successive calls to Deadline return the same results.
MultiContext returns the earliest deadline of all child contexts. If no child context have a deadline, it returns a zero-value for deadline, and ok==false
func (MultiContext) Done ¶
func (mc MultiContext) Done() <-chan struct{}
Done returns a channel that's closed when work done on behalf of this context should be canceled. Done may return nil if this context can never be canceled. Successive calls to Done return the same value. The close of the Done channel may happen asynchronously, after the cancel function returns.
MultiContext returns a channel that will be closed if any of the channels of the child context is closed.
func (MultiContext) Err ¶
func (mc MultiContext) Err() error
If Done is not yet closed, Err returns nil. If Done is closed, Err returns a non-nil error explaining why: Canceled if the context was canceled or DeadlineExceeded if the context's deadline passed. After Err returns a non-nil error, successive calls to Err return the same error.
MultiContext returns the error from the first child context that returns one. If no child context return an error, it returns nil.
func (MultiContext) Value ¶
func (mc MultiContext) Value(key any) any
Value returns the value associated with this context for key, or nil if no value is associated with key. Successive calls to Value with the same key returns the same result.
MultiContext returns the value from the first child context that returns a non-nil value. If no child context returns a value, it returns nil.