correlation

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package correlation defines validated, transport-neutral request correlation identities. It never exposes arbitrary metadata to observability sinks.

Index

Constants

View Source
const (
	// RequestIDMetadataKey is the one explicitly supported inbound correlation
	// key. Other metadata remains unavailable to completion logging.
	RequestIDMetadataKey = "x-request-id"

	// MaxRequestIDBytes bounds log and trace storage for one request identity.
	MaxRequestIDBytes = 128
)

Variables

View Source
var ErrInvalidRequestID = errors.New("correlation: invalid request id")

ErrInvalidRequestID reports an empty, oversized, ambiguous, or malformed ID.

Functions

func ParseRequestID

func ParseRequestID(value string) (string, error)

ParseRequestID validates one stable ASCII request identity. Padding and control characters are rejected instead of normalized to avoid ambiguity.

func PropagateRequestID added in v0.0.4

func PropagateRequestID() middleware.Middleware

PropagateRequestID promotes an already validated inbound request ID into the typed context used by downstream handlers and observability. Missing request IDs remain optional; callers that require one should use RequireRequestID instead.

func RequestID

func RequestID(ctx context.Context) (string, bool)

RequestID returns the validated typed identity when middleware published it. Before policy middleware runs, it may read only the explicitly supported inbound metadata key and applies the same validation contract.

func RequireRequestID

func RequireRequestID() middleware.Middleware

RequireRequestID rejects calls without exactly one validated request ID and publishes the typed value to downstream handlers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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