package
1.0.9
Repository: https://github.com/jamestrandung/go-context.git
Documentation: pkg.go.dev

# README

Context Extension

This package offers extra functionality we need from contexts that is not available in the standard context package.

Functions

func Detach

// Detach returns a context that keeps all values of the parent context
// but detaches from its cancellation and error handling.
func Detach(ctx context.Context) context.Context

This function comes in handy when some code needs to follow through to completion instead of getting cancelled halfway by the parent context (e.g. cancelled by)

func Delegate

// Delegate returns a context that keeps all values of the valueCtx while
// taking its cancellation signal and error from the cancelCtx.
func Delegate(cancelCtx context.Context, valueCtx context.Context) context.Context

The standard Context in Go is meant for 2 distinct purposes: carrying request-level data and looking out for cancelling signals. In cases where we want to delegate these responsibilities to 2 different Contexts, this function will get the job done.

# Functions

Delegate returns a context that keeps all values of the valueCtx while taking its cancellation signal and error from the cancelCtx.
Detach returns a context that keeps all values of the parent context but detaches from its cancellation and error handling.
WithAcyclicBreadcrumb return a new context with the given breadcrumbID embedded inside and true if this ID has never been encountered in the execution path before.