pub struct Options { /* private fields */ }Expand description
Options store for reading configuration values.
Implementations§
Source§impl Options
impl Options
Sourcepub fn builder<'a>() -> InitBuilder<'a>
pub fn builder<'a>() -> InitBuilder<'a>
Returns a builder for constructing an Options instance or
initializing the global store.
Configure optional parameters with the with_* methods, then finalize
with InitBuilder::build for a standalone instance or
InitBuilder::init for the global store.
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Load options using fallback chain: SENTRY_OPTIONS_DIR env var, then /etc/sentry-options
if it exists, otherwise sentry-options/.
Expects {dir}/schemas/ and {dir}/values/ subdirectories.
Sourcepub fn new_with_propagation_callback(
callback: PropagationCallback,
) -> Result<Self>
pub fn new_with_propagation_callback( callback: PropagationCallback, ) -> Result<Self>
Like [new], but with a propagation callback that fires (namespace, delay_secs)
whenever values are refreshed with a new generated_at timestamp.
Sourcepub fn from_directory(base_dir: &Path) -> Result<Self>
pub fn from_directory(base_dir: &Path) -> Result<Self>
Load options from a specific directory (useful for testing).
Expects {base_dir}/schemas/ and {base_dir}/values/ subdirectories.
Sourcepub fn from_schemas(schemas: &[(&str, &str)]) -> Result<Self>
pub fn from_schemas(schemas: &[(&str, &str)]) -> Result<Self>
Load options with schemas provided as in-memory JSON strings. Values are loaded from disk using the standard fallback chain.
Sourcepub fn get(&self, namespace: &str, key: &str) -> Result<Value>
pub fn get(&self, namespace: &str, key: &str) -> Result<Value>
Get an option value, returning the schema default if not set.
Sourcepub fn refresh(&self) -> Result<bool>
pub fn refresh(&self) -> Result<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 and served. Callbacks registered with
InitBuilder::with_callback fire on the calling thread before this
returns.
Any call resets the refresh-on-read timer, so calling this more often than the staleness threshold guarantees reads never refresh inline.