ctxutil

package
v0.1.0-develop.2026060... Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package ctxutil provides small context.Context helpers for crossing cancellation boundaries that the standard library does not directly model.

Scope: critical-write paths (security cascade revoke, compensating cleanup, audit flush) where caller cancellation must NOT abort the write. dev/debug scenarios that just want "ignore cancel" should use stdlib context.WithoutCancel directly; this package layers a bounded timeout on top so detached writes cannot leak goroutines.

ref: golang/go context.WithoutCancel proposal#40221 ref: hashicorp/vault vault/token_store.go (quitContext detached pattern)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDetachedTimeout

func WithDetachedTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

WithDetachedTimeout returns a context that inherits all Values from parent (trace IDs, auth principal, request id) but is NOT canceled when parent is canceled, and carries its own absolute deadline.

Use this for critical writes that must complete regardless of caller cancellation: cascade revoke on reuse detection, compensating cleanup, audit log flush. Do NOT use for happy-path reads/writes — caller cancellation usually carries useful "stop wasting work" signal.

The returned cancel must always be called (typically via defer) to release the timer regardless of which way the context is finished.

Implementation: context.WithoutCancel breaks the cancel chain (Done() is nil-channel, Err() is nil) while preserving Value lookup; WithTimeout adds a fresh deadline on top.

Types

This section is empty.

Jump to

Keyboard shortcuts

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