correlation

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package correlation normalizes correlation IDs and carries them through explicit contexts. Correlation is diagnostic metadata, never authorization or ownership authority.

Index

Examples

Constants

View Source
const DefaultHeader = "X-Correlation-ID"

DefaultHeader is the correlation header used at HTTP ingress.

Variables

View Source
var ErrInvalidID = errors.New("invalid correlation ID")

ErrInvalidID identifies malformed, missing, or zero correlation input.

Functions

func WithID

func WithID(ctx context.Context, id ID) context.Context

WithID installs the ID using Fundamentals.Go's shared context key; zero shadows an inherited ID. Correlation grants no authority. It panics if ctx is nil.

Types

type ID

type ID = concepts.UUID

ID aliases the approved UUID value used by command/query results.

func FromContext

func FromContext(ctx context.Context) ID

FromContext reads Fundamentals.Go's shared context key, returns zero when absent, and never generates an ID. It panics if ctx is nil.

func Normalize

func Normalize(text string) (ID, error)

Normalize replaces invalid input with a new UUID, preserving generation failures.

func Parse

func Parse(text string) (ID, error)

Parse trims surrounding whitespace and accepts nonzero dashed UUIDs.

func Resolve

func Resolve(ctx context.Context, text string) (ID, error)

Resolve prefers valid supplied text, then a nonzero context ID, then generation.

Example
package main

import (
	"context"
	"fmt"

	"github.com/cratis/arc.go/correlation"
)

func main() {
	id, err := correlation.Resolve(context.Background(), "12345678-ABCD-4ABC-8DEF-123456789012")
	if err != nil {
		panic(err)
	}
	fmt.Println(id)
}
Output:
12345678-abcd-4abc-8def-123456789012

Jump to

Keyboard shortcuts

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