From 06d99414354656b38a85ce2ad7ab196e25f0b720 Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Tue, 14 Sep 2021 11:54:40 +0100 Subject: [PATCH] chore: use RuleSchedule enum and new run_monitor_rule --- src/clouds/monitor_rules.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/clouds/monitor_rules.rs b/src/clouds/monitor_rules.rs index a1f0a06..c18ff90 100644 --- a/src/clouds/monitor_rules.rs +++ b/src/clouds/monitor_rules.rs @@ -79,6 +79,30 @@ impl MonitorAction { } } +#[derive(Eq, PartialEq, Copy, Clone, Debug, Serialize, Deserialize)] +pub enum RuleSchedule { + None, + Check, + OnDemand, +} + +impl Default for RuleSchedule { + fn default() -> Self { + RuleSchedule::None + } +} + +impl fmt::Display for RuleSchedule { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + RuleSchedule::None => write!(f,"none"), + RuleSchedule::Check=> write!(f,"chechk"), + RuleSchedule::OnDemand=> write!(f,"ondemand"), + } + } +} + + #[derive(Eq, PartialEq, Copy, Clone, Debug, Serialize, Deserialize)] pub enum RuleOperator { None, @@ -166,7 +190,8 @@ pub struct MonitorRule { pub value: String, pub result: bool, pub use_state: bool, - pub schedule: String, + pub wait_checks: isize, + pub schedule: RuleSchedule, #[serde(deserialize_with = "deserialize_ruleactions")] pub actions: Vec, }