pub struct ValuesStore { /* private fields */ }Expand description
Lazily reloads values from disk when reads detect they are stale.
Holds the current ValuesByNamespace snapshot in an ArcSwap for
lock-free reads. Every load() checks whether the snapshot is older than
refresh_threshold + jitter; if so, the calling thread reads the values
directory, then compare-and-swaps the timestamp. Whichever thread wins the
CAS publishes its snapshot into the ArcSwap; losers discard their work.
Replaces the polling watcher thread: idle processes do no work, and concurrent readers coordinate through the timestamp CAS.
Implementations§
Source§impl ValuesStore
impl ValuesStore
Sourcepub fn new(
registry: Arc<SchemaRegistry>,
values_dir: &Path,
) -> ValidationResult<Self>
pub fn new( registry: Arc<SchemaRegistry>, values_dir: &Path, ) -> ValidationResult<Self>
Build a store and perform the initial values load synchronously.
Sourcepub fn registry(&self) -> &Arc<SchemaRegistry>
pub fn registry(&self) -> &Arc<SchemaRegistry>
The registry the store was constructed with.
Sourcepub fn load(&self) -> Guard<Arc<ValuesByNamespace>>
pub fn load(&self) -> Guard<Arc<ValuesByNamespace>>
Returns a guard onto the current values snapshot, refreshing first if
the cached snapshot is older than refresh_threshold + jitter.