Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mixin ¶
func Mixin(longctx, shortctx context.Context) (mixedctx context.Context, mixedcancel context.CancelFunc)
Mixin mixes a typically shorter-lived (service, etc.) context passed in “shortctx” into a long-living context “longctx”, returning a derived “mixed” context. The “mixed” context is derived from the long-living context and additionally gets the deadline (if any) and cancellation of the mixed-in “shortctx”.
Please note that it is essential to always call the additionally returned cancel function in order to not leak go routines. Calling this cancel function won't cancel the long-living and short-lived contexts, just clean up. This follows the established context pattern of context.WithCancel, context.WithDeadline and context.WithTimeout.
Types ¶
This section is empty.