pub struct ValuesStore { /* private fields */ }Expand description
Validates and serves option values, reloading them lazily on read and
serving the current snapshot lock-free via ArcSwap. See refresh for the
staleness window and memory-ordering details.
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>
Builds a store with the default configuration and performs the initial values load synchronously.
Use builder to override the configuration.
Sourcepub fn with_propagation_callback(
registry: Arc<SchemaRegistry>,
values_dir: &Path,
callback: PropagationCallback,
) -> ValidationResult<Self>
👎Deprecated: use ValuesStore::builder(...).with_callback(...) instead
pub fn with_propagation_callback( registry: Arc<SchemaRegistry>, values_dir: &Path, callback: PropagationCallback, ) -> ValidationResult<Self>
use ValuesStore::builder(...).with_callback(...) instead
Builds a store with a callback that fires whenever new values are detected.
Sourcepub fn builder(
registry: Arc<SchemaRegistry>,
values_dir: &Path,
) -> ValuesStoreBuilder
pub fn builder( registry: Arc<SchemaRegistry>, values_dir: &Path, ) -> ValuesStoreBuilder
Returns a builder for constructing a store from the given registry and values directory.
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.
Sourcepub fn force_load(&self) -> Guard<Arc<ValuesByNamespace>>
pub fn force_load(&self) -> Guard<Arc<ValuesByNamespace>>
Like load, but always refreshes, ignoring the staleness
threshold. The mtime check still applies, so unchanged files are not
re-read from disk.
Sourcepub fn refresh(&self) -> ValidationResult<bool>
pub fn refresh(&self) -> ValidationResult<bool>
Refreshes values from disk, ignoring the staleness threshold.
Returns whether a new snapshot was published, i.e. the files changed on disk (by mtime) and reloaded successfully. On error the previous snapshot is retained. Propagation callbacks fire on the calling thread before this returns.
Any call resets the refresh-on-read timer, so calling this more often than the threshold guarantees reads never refresh inline.