pub struct ConfigurationServiceImpl {
name: String,
config: Arc<RwLock<HashMap<String, ConfigurationValue>>>,
config_paths: Arc<RwLock<HashMap<ConfigurationScope, PathBuf>>>,
running: Arc<RwLock<bool>>,
watchers: Arc<RwLock<HashMap<String, Vec<Arc<RwLock<dyn Fn(String, Value) -> Result<()> + Send + Sync>>>>>>,
}
Expand description
Configuration service
Fields§
§name:
String
Service name
config:
Arc<RwLock<HashMap<String,
ConfigurationValue>>>
Configuration data
config_paths:
Arc<RwLock<HashMap<ConfigurationScope,
PathBuf>>>
Configuration paths
running:
Arc<RwLock<bool>>
Running flag
watchers:
Arc<RwLock<HashMap<String,
Vec<Arc<RwLock<dyn
Fn(String,
Value) ->
Result<()> +
Send
+
Sync>>>>>>
Watchers
Implementations§
Source§
impl
ConfigurationServiceImpl
impl ConfigurationServiceImpl
Source
pub async fn
get_with_default(&self, key: &str, default:
Value) ->
Value
pub async fn get_with_default(&self, key: &str, default: Value) -> Value
Get a configuration value with a default
Source
pub async fn
set( &self, key:
String, value:
Value, scope:
ConfigurationScope, ) ->
Result<()>
pub async fn set( &self, key: String, value: Value, scope: ConfigurationScope, ) -> Result<()>
Set a configuration value
Source
pub async fn
get_all_in_scope( &self, scope:
ConfigurationScope, ) ->
HashMap<String,
Value>
pub async fn get_all_in_scope( &self, scope: ConfigurationScope, ) -> HashMap<String, Value>
Get all configuration values in a scope
Source
pub async fn
load_from_file( &self, path: &Path, scope:
ConfigurationScope, ) ->
Result<()>
pub async fn load_from_file( &self, path: &Path, scope: ConfigurationScope, ) -> Result<()>
Load configuration from a file
Source
pub async fn
load_from_value( &self, value:
Value, scope:
ConfigurationScope, ) ->
Result<()>
pub async fn load_from_value( &self, value: Value, scope: ConfigurationScope, ) -> Result<()>
Load configuration from a value
Source
pub async fn
save_to_file( &self, path: &Path, scope:
ConfigurationScope, ) ->
Result<()>
pub async fn save_to_file( &self, path: &Path, scope: ConfigurationScope, ) -> Result<()>
Save configuration to a file
Source
pub async fn
register_watcher<F>(&self, key:
String, callback: F)
pub async fn register_watcher<F>(&self, key: String, callback: F)
Register a configuration watcher
Source
pub async fn
unregister_watcher(&self, key:
String) ->
Result<bool>
pub async fn unregister_watcher(&self, key: String) -> Result<bool>
Unregister a configuration watcher
Source
async fn
notify_watchers(&self, key:
String, value:
Value)
async fn notify_watchers(&self, key: String, value: Value)
Notify watchers of configuration changes
Source
pub async fn
get_config_paths(&self) ->
HashMap<ConfigurationScope,
PathBuf>
pub async fn get_config_paths(&self) -> HashMap<ConfigurationScope, PathBuf>
Get configuration paths
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConfigurationServiceImpl
impl !RefUnwindSafe for ConfigurationServiceImpl
impl Send for ConfigurationServiceImpl
impl Sync for ConfigurationServiceImpl
impl Unpin for ConfigurationServiceImpl
impl UnsafeUnpin for ConfigurationServiceImpl
impl !UnwindSafe for ConfigurationServiceImpl
Blanket Implementations§
Source§
impl<T>
BorrowMut<T> for T
where T: ?Sized,
impl<T>
BorrowMut<T> for T
where T: ?Sized,
Source§
fn
borrow_mut(&mut self) ->
&mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value.
Read more
§
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>
Converts
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 more
Source§
fn
into_either_with<F>(self, into_left: F)
->
Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
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
Source§
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>
Wrap the input message
T in
a tonic::Request