sentry-options-validation 1.0.11

Schema validation library and CLI for sentry-options
Documentation

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:

  1. Read now and last_updated (an AtomicU64 of nanoseconds since a monotonic baseline) with Acquire.
  2. 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. No thread_local is involved.
  3. 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 the ArcSwap (last-writer-wins under contention). c. compare_exchange last_updated from the previously-observed value to now with AcqRel. The Release on the timestamp publishes the prior ArcSwap::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.