debug + casting

feature/configv2
prplV 2025-04-22 11:18:36 -04:00
parent 28092d945a
commit 502ea114a6
1 changed files with 12 additions and 4 deletions

View File

@ -8,6 +8,7 @@ pub enum DependencyType {
Service, Service,
} }
#[derive(Debug)]
pub enum ServiceState { pub enum ServiceState {
Ok, Ok,
Unavailable Unavailable
@ -49,17 +50,24 @@ impl<'a> FileTriggerType {
} }
} }
#[derive(Debug)]
pub enum Triggers<'a> { pub enum Triggers<'a> {
File{ on_change: &'a str, on_delete: &'a str }, File{ on_change: &'a str, on_delete: &'a str },
Service(&'a str), Service{on_lost: &'a str, wait: u32},
} }
impl<'a> Triggers<'a> { impl<'a> Triggers<'a> {
pub fn new_file(on_change: &'a str, on_delete: &'a str) -> Triggers<'a> { pub fn new_file(on_change: &'a str, on_delete: &'a str) -> Triggers<'a> {
Triggers::File { on_change, on_delete } Triggers::File { on_change, on_delete }
} }
pub fn new_service(on_lost: &'a str) -> Triggers<'a> { pub fn new_service(on_lost: &'a str, wait_time: u32) -> Triggers<'a> {
Triggers::Service(on_lost) Triggers::Service{on_lost, wait: wait_time}
}
pub fn to_service_negative_event(&'a self, service_name: &'a str) -> Option<Events<'a>> {
if let Triggers::Service { on_lost, .. } = self {
return Some(Events::Negative(NegativeOutcomes::ServiceIsUnreachable(service_name, DependencyType::Service, &on_lost)))
}
None
} }
} }
@ -92,7 +100,7 @@ pub enum NegativeOutcomes<'a> {
} }
pub trait ProcessUnit<'a> { pub trait ProcessUnit<'a> {
fn process(&mut self) -> impl std::future::Future<Output = ()> + Send; fn process(&'a mut self) -> impl std::future::Future<Output = ()> + Send;
} }
/// # an Error enum (next will be deleted and replaced) /// # an Error enum (next will be deleted and replaced)