Small helpers for consistent context.Context handling.
Overview
The ctxutil package centralizes context fallback conventions used across the repository. It currently exposes a single helper, OrBackground, for call sites that accept an optional context and need a non-nil context.Context before invoking context-aware APIs.
Public API
Functions
Function
Signature
Description
OrBackground
func(ctx context.Context) context.Context
Returns context.Background() when ctx is nil; otherwise returns ctx unchanged
Usage Examples
ctx := ctxutil.OrBackground(ctx)
Dependencies
External:
None beyond the Go standard library (context).
This specification is automatically maintained by the spec-extractor workflow.
OrBackground centralizes the repo's nil-context fallback convention: it
returns context.Background() when ctx is nil, otherwise it returns ctx
unchanged. Use this instead of duplicating the inline