ids

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package ids provides trace IDs and deterministic hashes derived from named request values.

Index

Constants

View Source
const AllZeroKeyHash = "0000000000000000"

AllZeroKeyHash is the key_hash for requests with no Authorization/x-api-key header. File names like "data/<date>/00000000.jsonl" come from this.

View Source
const KeyHashLen = 16

KeyHashLen is the canonical length of key_hash in SQLite (16 hex chars = 64 bits). File names use only the first 8 chars (key_hash[:8]) for brevity. See ARCHITECTURE § 2 for the full definition.

Variables

This section is empty.

Functions

func KeyHashFromHeaders

func KeyHashFromHeaders(h http.Header) string

KeyHashFromHeaders computes the canonical key_hash for a request's auth headers. Preference order (per ARCHITECTURE § 2):

  1. Authorization header value (including any "Bearer " prefix)
  2. x-api-key header value
  3. empty string → AllZeroKeyHash

The hash is the lowercase hex of sha256 truncated to KeyHashLen chars.

func KeyHashShort

func KeyHashShort(keyHash string) string

KeyHashShort returns the first 8 hex chars of a key_hash. Used for file naming.

func NewTraceID

func NewTraceID() string

NewTraceID returns a new ULID for the current time using the package entropy source. Safe for concurrent use.

Types

This section is empty.

Jump to

Keyboard shortcuts

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