pub struct MonitorService<M: MonitorRepositoryTrait<N, T> + Send, N: NetworkRepositoryTrait + Send + Sync + 'static, T: TriggerRepositoryTrait + Send + Sync + 'static> { /* private fields */ }
Expand description
Service layer for monitor repository operations
This type provides a higher-level interface for working with monitor configurations, handling repository initialization and access through a trait-based interface. It also ensures that all monitor references to networks and triggers are valid.
Implementations§
Source§impl<M: MonitorRepositoryTrait<N, T> + Send, N: NetworkRepositoryTrait + Send + Sync + 'static, T: TriggerRepositoryTrait + Send + Sync + 'static> MonitorService<M, N, T>
impl<M: MonitorRepositoryTrait<N, T> + Send, N: NetworkRepositoryTrait + Send + Sync + 'static, T: TriggerRepositoryTrait + Send + Sync + 'static> MonitorService<M, N, T>
Sourcepub async fn new(
path: Option<&Path>,
network_service: Option<NetworkService<N>>,
trigger_service: Option<TriggerService<T>>,
) -> Result<MonitorService<M, N, T>, RepositoryError>
pub async fn new( path: Option<&Path>, network_service: Option<NetworkService<N>>, trigger_service: Option<TriggerService<T>>, ) -> Result<MonitorService<M, N, T>, RepositoryError>
Create a new monitor service with the default repository implementation
Loads monitor configurations from the specified path (or default config directory) and validates all network and trigger references.
Sourcepub async fn new_with_path(
path: Option<&Path>,
) -> Result<MonitorService<M, N, T>, RepositoryError>
pub async fn new_with_path( path: Option<&Path>, ) -> Result<MonitorService<M, N, T>, RepositoryError>
Create a new monitor service with a specific configuration path
Similar to new()
but makes the path parameter more explicit.
Sourcepub fn new_with_repository(repository: M) -> Result<Self, RepositoryError>
pub fn new_with_repository(repository: M) -> Result<Self, RepositoryError>
Create a new monitor service with a custom repository implementation
Allows for using alternative storage backends that implement the MonitorRepositoryTrait.
Sourcepub fn get(&self, monitor_id: &str) -> Option<Monitor>
pub fn get(&self, monitor_id: &str) -> Option<Monitor>
Get a specific monitor by ID
Returns None if the monitor doesn’t exist.
Sourcepub fn get_all(&self) -> HashMap<String, Monitor>
pub fn get_all(&self) -> HashMap<String, Monitor>
Get all monitors
Returns a copy of the monitor map to prevent external mutation.
Sourcepub async fn load_from_path(
&self,
path: Option<&Path>,
network_service: Option<NetworkService<N>>,
trigger_service: Option<TriggerService<T>>,
) -> Result<Monitor, RepositoryError>
pub async fn load_from_path( &self, path: Option<&Path>, network_service: Option<NetworkService<N>>, trigger_service: Option<TriggerService<T>>, ) -> Result<Monitor, RepositoryError>
Load a monitor from a specific path
Loads a monitor configuration from a specific path and validates all network and trigger references.
Trait Implementations§
Source§impl<M: Clone + MonitorRepositoryTrait<N, T> + Send, N: Clone + NetworkRepositoryTrait + Send + Sync + 'static, T: Clone + TriggerRepositoryTrait + Send + Sync + 'static> Clone for MonitorService<M, N, T>
impl<M: Clone + MonitorRepositoryTrait<N, T> + Send, N: Clone + NetworkRepositoryTrait + Send + Sync + 'static, T: Clone + TriggerRepositoryTrait + Send + Sync + 'static> Clone for MonitorService<M, N, T>
Source§fn clone(&self) -> MonitorService<M, N, T>
fn clone(&self) -> MonitorService<M, N, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<M, N, T> Freeze for MonitorService<M, N, T>where
M: Freeze,
impl<M, N, T> RefUnwindSafe for MonitorService<M, N, T>
impl<M, N, T> Send for MonitorService<M, N, T>
impl<M, N, T> Sync for MonitorService<M, N, T>where
M: Sync,
impl<M, N, T> Unpin for MonitorService<M, N, T>
impl<M, N, T> UnwindSafe for MonitorService<M, N, T>
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for 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> 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