Expand description
Schema validation library for sentry-options.
Schemas are loaded once into a SchemaRegistry and shared via Arc.
Values are validated against schemas as complete objects.
§Refresh-on-read scheme
Values are held in a ValuesStore that wraps an ArcSwap for
lock-free reads. There is no background thread — every load() decides
whether the cached snapshot is stale and, if so, the calling thread
refreshes it.
Each load() does:
- Read
nowandlast_updated(anAtomicU64of nanoseconds since a monotonic baseline) withAcquire. - Compute a per-call jitter in
[0, 1s)from the address of a stack local — different threads have different stack bases, so the value differs across threads. Nothread_localis involved. - If
now - last_updated < threshold + jitter, return the current snapshot. Otherwise: a. Read all values files from disk and build the new map. b. On success, publish the new map into theArcSwap(last-writer-wins under contention). c.compare_exchangelast_updatedfrom the previously-observed value tonowwithAcqRel. The Release on the timestamp publishes the priorArcSwap::store: any reader that Acquire-loads the bumped timestamp and short-circuits the refresh is guaranteed to subsequently load the new snapshot. d. On a parse/validation failure, leave the old map in place — the bumped timestamp makes other threads back off until the next window.
Multiple threads racing through the stale window will redundantly read
files and publish; the last ArcSwap::store wins. The jitter spreads
the threshold boundary so that the herd doesn’t cross it together. On
error the timestamp is still bumped so a broken values directory does
not turn into an I/O storm.
Structs§
- Namespace
Schema - Schema for a namespace, containing validator and option metadata
- Option
Metadata - Metadata for a single option in a namespace schema
- Schema
Registry - Registry for loading and storing schemas
- Values
Store - Lazily reloads values from disk when reads detect they are stale.
Enums§
- Validation
Error - Errors that can occur during schema and value validation
Constants§
- LOCAL_
OPTIONS_ DIR - Local fallback path for development
- OPTIONS_
DIR_ ENV - Environment variable to override options directory
- OPTIONS_
SUPPRESS_ MISSING_ DIR_ ENV - Environment variable to suppress missing directory errors
- PRODUCTION_
OPTIONS_ DIR - Production path where options are deployed via config map
Functions§
- resolve_
options_ dir - Resolve options directory using fallback chain:
- validate_
k8s_ name_ component - Validate a name component is valid for K8s (lowercase alphanumeric, ‘-’, ‘.’)
Type Aliases§
- Validation
Result - Result type for validation operations
- Values
ByNamespace - A map of option values keyed by their namespace