chore: use RuleSchedule enum and new run_monitor_rule

This commit is contained in:
Jesús Pérez Lorenzo 2021-09-14 11:54:40 +01:00
parent 50eb1c23bd
commit 06d9941435

View File

@ -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<MonitorAction>,
}