pub struct RiConfigManager { /* private fields */ }Expand description
Public-facing configuration manager with hot reload support.
This struct manages multiple configuration sources, loads configuration values, and provides access to the configuration. It supports hot reload and multiple configuration formats.
Implementations§
Source§impl RiConfigManager
impl RiConfigManager
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty configuration manager.
Returns a new RiConfigManager instance with no configuration sources.
Sourcepub fn with_hooks(hooks: Arc<RiHookBus>) -> Self
pub fn with_hooks(hooks: Arc<RiHookBus>) -> Self
Sourcepub fn add_file_source(&mut self, path: impl AsRef<Path>)
pub fn add_file_source(&mut self, path: impl AsRef<Path>)
Adds a file-based configuration source.
§Parameters
path: The path to the configuration file
Supported file formats: JSON, YAML, TOML
Sourcepub fn add_environment_source(&mut self)
pub fn add_environment_source(&mut self)
Adds environment variables as a configuration source.
Environment variables with the prefix Ri_ are loaded as configuration values.
Double underscores (__) in environment variable names are converted to dots.
For example, Ri_SERVER__PORT=8080 becomes server.port=8080.
Sourcepub fn load(&mut self) -> Result<(), RiError>
pub fn load(&mut self) -> Result<(), RiError>
Loads configuration from all registered sources.
This method loads configuration from all registered sources in the order they were added, with later sources overriding earlier ones.
§Returns
A Result<(), RiError> indicating success or failure
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Creates a new configuration manager with default sources.
This method creates a new RiConfigManager with the following default sources:
- Configuration files in the
configdirectory (dms.yaml, dms.yml, dms.toml, dms.json) - Environment variables with the prefix
Ri_
It also loads the configuration immediately.
§Returns
A new RiConfigManager instance with default sources and loaded configuration
Sourcepub async fn start_watcher(&mut self) -> Result<(), RiError>
pub async fn start_watcher(&mut self) -> Result<(), RiError>
Starts the configuration watcher for hot reload.
This method starts watching all registered file-based configuration sources for changes. When a configuration file is modified, it will be automatically reloaded and the change callback (if registered) will be invoked.
§Returns
A Result<(), RiError> indicating success or failure
Sourcepub async fn start_watcher_with_callback<F>(
&mut self,
callback: Option<Arc<dyn Fn() + Send + Sync>>,
) -> Result<(), RiError>
pub async fn start_watcher_with_callback<F>( &mut self, callback: Option<Arc<dyn Fn() + Send + Sync>>, ) -> Result<(), RiError>
Starts the configuration watcher with a custom change callback.
This method starts watching all registered file-based configuration sources for changes. When a configuration file is modified, it will be automatically reloaded and the provided callback will be invoked.
§Parameters
callback: Optional callback function to invoke when configuration changes
§Returns
A Result<(), RiError> indicating success or failure
Sourcepub async fn stop_watcher(&mut self) -> Result<(), RiError>
pub async fn stop_watcher(&mut self) -> Result<(), RiError>
Stops the configuration watcher.
This method stops the configuration watcher and cleans up associated resources.
§Returns
A Result<(), RiError> indicating success or failure
Sourcepub async fn get_monitored_paths(&self) -> Vec<PathBuf>
pub async fn get_monitored_paths(&self) -> Vec<PathBuf>
Gets the list of monitored configuration file paths.
§Returns
A vector of paths being monitored for changes
Sourcepub fn config_mut(&mut self) -> RwLockWriteGuard<'_, RiConfig>
pub fn config_mut(&mut self) -> RwLockWriteGuard<'_, RiConfig>
Gets a mutable reference to the loaded configuration.
§Returns
A std::sync::RwLockWriteGuard<RiConfig> for the loaded configuration
Trait Implementations§
Source§impl Clone for RiConfigManager
impl Clone for RiConfigManager
Source§impl Default for RiConfigManager
impl Default for RiConfigManager
Source§impl<'py> IntoPyObject<'py> for RiConfigManager
impl<'py> IntoPyObject<'py> for RiConfigManager
Source§type Target = RiConfigManager
type Target = RiConfigManager
Source§type Output = Bound<'py, <RiConfigManager as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <RiConfigManager as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for RiConfigManager
impl PyClass for RiConfigManager
Source§impl PyClassImpl for RiConfigManager
impl PyClassImpl for RiConfigManager
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// configuration formats.
const RAW_DOC: &'static CStr = /// configuration formats.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<RiConfigManager>
type ThreadChecker = SendablePyClass<RiConfigManager>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for RiConfigManager
impl PyClassNewTextSignature for RiConfigManager
const TEXT_SIGNATURE: &'static str = "()"
Source§impl PyMethods<RiConfigManager> for PyClassImplCollector<RiConfigManager>
impl PyMethods<RiConfigManager> for PyClassImplCollector<RiConfigManager>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for RiConfigManager
impl PyTypeInfo for RiConfigManager
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for RiConfigManager
impl ExtractPyClassWithClone for RiConfigManager
Auto Trait Implementations§
impl Freeze for RiConfigManager
impl !RefUnwindSafe for RiConfigManager
impl Send for RiConfigManager
impl Sync for RiConfigManager
impl Unpin for RiConfigManager
impl UnsafeUnpin for RiConfigManager
impl !UnwindSafe for RiConfigManager
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more