pub struct DMSCConfigManager { /* 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 DMSCConfigManager
impl DMSCConfigManager
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty configuration manager.
Returns a new DMSCConfigManager instance with no configuration sources.
Sourcepub fn with_hooks(hooks: Arc<DMSCHookBus>) -> Self
pub fn with_hooks(hooks: Arc<DMSCHookBus>) -> 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 DMSC_ are loaded as configuration values.
Double underscores (__) in environment variable names are converted to dots.
For example, DMSC_SERVER__PORT=8080 becomes server.port=8080.
Sourcepub fn load(&mut self) -> Result<(), DMSCError>
pub fn load(&mut self) -> Result<(), DMSCError>
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<(), DMSCError> 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 DMSCConfigManager with the following default sources:
- Configuration files in the
configdirectory (dms.yaml, dms.yml, dms.toml, dms.json) - Environment variables with the prefix
DMSC_
It also loads the configuration immediately.
§Returns
A new DMSCConfigManager instance with default sources and loaded configuration
Sourcepub async fn start_watcher(&mut self) -> Result<(), DMSCError>
pub async fn start_watcher(&mut self) -> Result<(), DMSCError>
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<(), DMSCError> indicating success or failure
Sourcepub async fn start_watcher_with_callback<F>(
&mut self,
callback: Option<Arc<dyn Fn() + Send + Sync>>,
) -> Result<(), DMSCError>
pub async fn start_watcher_with_callback<F>( &mut self, callback: Option<Arc<dyn Fn() + Send + Sync>>, ) -> Result<(), DMSCError>
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<(), DMSCError> indicating success or failure
Sourcepub async fn stop_watcher(&mut self) -> Result<(), DMSCError>
pub async fn stop_watcher(&mut self) -> Result<(), DMSCError>
Stops the configuration watcher.
This method stops the configuration watcher and cleans up associated resources.
§Returns
A Result<(), DMSCError> 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(&self) -> DMSCConfig
pub fn config(&self) -> DMSCConfig
Gets a reference to the loaded configuration.
§Returns
A DMSCConfig clone of the loaded configuration
Sourcepub fn config_mut(&mut self) -> RwLockWriteGuard<'_, DMSCConfig>
pub fn config_mut(&mut self) -> RwLockWriteGuard<'_, DMSCConfig>
Gets a mutable reference to the loaded configuration.
§Returns
A std::sync::RwLockWriteGuard<DMSCConfig> for the loaded configuration
Trait Implementations§
Source§impl Clone for DMSCConfigManager
impl Clone for DMSCConfigManager
Source§impl Default for DMSCConfigManager
impl Default for DMSCConfigManager
Source§impl<'py> IntoPyObject<'py> for DMSCConfigManager
impl<'py> IntoPyObject<'py> for DMSCConfigManager
Source§type Target = DMSCConfigManager
type Target = DMSCConfigManager
Source§type Output = Bound<'py, <DMSCConfigManager as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <DMSCConfigManager 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 DMSCConfigManager
impl PyClass for DMSCConfigManager
Source§impl PyClassImpl for DMSCConfigManager
impl PyClassImpl for DMSCConfigManager
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<DMSCConfigManager>
type ThreadChecker = SendablePyClass<DMSCConfigManager>
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 DMSCConfigManager
impl PyClassNewTextSignature for DMSCConfigManager
const TEXT_SIGNATURE: &'static str = "()"
Source§impl PyMethods<DMSCConfigManager> for PyClassImplCollector<DMSCConfigManager>
impl PyMethods<DMSCConfigManager> for PyClassImplCollector<DMSCConfigManager>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for DMSCConfigManager
impl PyTypeInfo for DMSCConfigManager
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 DMSCConfigManager
impl ExtractPyClassWithClone for DMSCConfigManager
Auto Trait Implementations§
impl Freeze for DMSCConfigManager
impl !RefUnwindSafe for DMSCConfigManager
impl Send for DMSCConfigManager
impl Sync for DMSCConfigManager
impl Unpin for DMSCConfigManager
impl !UnwindSafe for DMSCConfigManager
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