ctx

package
v4.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL