From fbd466a85cce1a1acac2e1ca6088f94249e3fe6c Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 5 May 2025 13:40:32 -0400 Subject: [PATCH] added file --- .../domain/topology/monitoring_alerting.rs | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 harmony/src/domain/topology/monitoring_alerting.rs diff --git a/harmony/src/domain/topology/monitoring_alerting.rs b/harmony/src/domain/topology/monitoring_alerting.rs new file mode 100644 index 0000000..a5e4743 --- /dev/null +++ b/harmony/src/domain/topology/monitoring_alerting.rs @@ -0,0 +1,59 @@ +use serde::Serialize; +use tokio::sync::OnceCell; + +use async_trait::async_trait; + +use crate::interpret::{InterpretError, Outcome}; + +use super::{HelmCommand, Topology}; + +#[derive(Clone, Debug)] +struct MonitoringState { + message: String, +} + +#[derive(Clone, Debug)] +pub struct MonitoringAlertingTopology { + monitoring_state: OnceCell>, +} + + +impl MonitoringAlertingTopology { + pub fn new() -> Self { + Self { + monitoring_state: OnceCell::new(), + } + } + fn get_monitoring_state(&self) -> Result, InterpretError> { + let state = MonitoringState { + message: "monitoring stack not installed".to_string(), + }; + Ok(Some(state)) + } +} + +#[async_trait] +impl Topology for MonitoringAlertingTopology { + fn name(&self) -> &str { + "MonitoringAlertingTopology" + } + + async fn ensure_ready(&self) -> Result { + let monitoring_state = self + .monitoring_state + .get_or_try_init(|| async { self.get_monitoring_state() }) + .await?; + + if monitoring_state.is_some() { + Ok(Outcome::success( + "Monitoring stack already installed".to_string(), + )) + } else { + Ok(Outcome::success( + "Monitoring stack not installed".to_string(), + )) + } + } +} + +impl HelmCommand for MonitoringAlertingTopology {}