pub struct SystemConfig(/* private fields */);Expand description
Registry of all runtime-tunable configuration entries.
Subsystems call register() at startup to declare their tunable parameters.
The bootstrap process calls apply_persisted() to override defaults with
values loaded from storage.
SystemConfig is cheaply cloneable — cloning increments an internal Arc
reference count without copying any data.
Implementations§
Source§impl SystemConfig
impl SystemConfig
pub fn new() -> Self
Sourcepub fn register(
&self,
key: &str,
default: Value,
description: &'static str,
requires_restart: bool,
)
pub fn register( &self, key: &str, default: Value, description: &'static str, requires_restart: bool, )
Register a configuration key with its default value and metadata.
The default value is inserted at CommitVersion(0) so it is visible to all transactions. If the key is already registered, this is a no-op.
Sourcepub fn apply_persisted(&self, key: &str, version: CommitVersion, value: Value)
pub fn apply_persisted(&self, key: &str, version: CommitVersion, value: Value)
Apply a persisted value loaded from storage during bootstrap.
If the key is not registered, the value is silently ignored (it may be from a removed config that no longer exists).
Sourcepub fn update(&self, key: &str, version: CommitVersion, value: Value)
pub fn update(&self, key: &str, version: CommitVersion, value: Value)
Update a config value at the given commit version (called from post-commit interceptor).
Panics if the key is not registered — callers must verify via get()
before calling this.
Sourcepub fn get_default(&self, key: &str) -> Option<Value>
pub fn get_default(&self, key: &str) -> Option<Value>
Get the registered default value for a config key.
Sourcepub fn get_at(&self, key: &str, version: CommitVersion) -> Option<Value>
pub fn get_at(&self, key: &str, version: CommitVersion) -> Option<Value>
Get the value for a config key as of a specific snapshot version.
Sourcepub fn get_uint8(&self, key: &str) -> Option<u64>
pub fn get_uint8(&self, key: &str) -> Option<u64>
Get the current value as a u64, or None if the key is not registered. Panics if the key is registered but the value is not Value::Uint8.
Sourcepub fn require_uint8(&self, key: &str) -> u64
pub fn require_uint8(&self, key: &str) -> u64
Get the current value as a u64, panicking if the key is not registered or the value is not Value::Uint8.
Sourcepub fn list_all(&self) -> Vec<ConfigDef>
pub fn list_all(&self) -> Vec<ConfigDef>
List all registered configuration entries with their latest values.
Sourcepub fn list_all_at(&self, version: CommitVersion) -> Vec<ConfigDef>
pub fn list_all_at(&self, version: CommitVersion) -> Vec<ConfigDef>
List all registered configuration entries with values as of a specific snapshot version.
Trait Implementations§
Source§impl Clone for SystemConfig
impl Clone for SystemConfig
Source§fn clone(&self) -> SystemConfig
fn clone(&self) -> SystemConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SystemConfig
impl Debug for SystemConfig
Auto Trait Implementations§
impl Freeze for SystemConfig
impl !RefUnwindSafe for SystemConfig
impl Send for SystemConfig
impl Sync for SystemConfig
impl Unpin for SystemConfig
impl UnsafeUnpin for SystemConfig
impl !UnwindSafe for SystemConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more