wip: removed AlertReceiverConfig
Some checks failed
Run Check Script / check (push) Failing after 44s
Run Check Script / check (pull_request) Failing after 44s

This commit is contained in:
Willem 2025-06-02 16:11:36 -04:00
parent 0d56fbc09d
commit a2be9457b9
2 changed files with 17 additions and 23 deletions

View File

@ -1,6 +1,5 @@
use async_trait::async_trait; use async_trait::async_trait;
use dyn_clone::DynClone;
use std::fmt::Debug; use std::fmt::Debug;
use url::Url; use url::Url;
@ -9,7 +8,7 @@ use crate::interpret::InterpretError;
use crate::{interpret::Outcome, topology::Topology}; use crate::{interpret::Outcome, topology::Topology};
/// Represents an entity responsible for collecting and organizing observability data /// Represents an entity responsible for collecting and organizing observability data
/// from various telemetry sources /// from various telemetry sources
/// A `Monitor` abstracts the logic required to scrape, aggregate, and structure /// A `Monitor` abstracts the logic required to scrape, aggregate, and structure
/// monitoring data, enabling consistent processing regardless of the underlying data source. /// monitoring data, enabling consistent processing regardless of the underlying data source.
#[async_trait] #[async_trait]
@ -17,23 +16,16 @@ pub trait Monitor<T: Topology>: Debug + Send + Sync {
async fn deploy_monitor( async fn deploy_monitor(
&self, &self,
topology: &T, topology: &T,
alert_receivers: Vec<Box<dyn AlertReceiver<T>>>, alert_receivers: Vec<AlertReceiver>,
) -> Result<Outcome, InterpretError>; ) -> Result<Outcome, InterpretError>;
async fn delete_monitor( async fn delete_monitor(
&self, &self,
topolgy: &T, topolgy: &T,
alert_receivers: Vec<Box<dyn AlertReceiver<T>>>, alert_receivers: Vec<AlertReceiver>,
) -> Result<Outcome, InterpretError>; ) -> Result<Outcome, InterpretError>;
} }
#[async_trait] pub struct AlertReceiver {
pub trait AlertReceiver<T>: Debug + DynClone + Send + Sync {
fn get_alert_receiver_config(&self) -> AlertReceiverConfig;
}
pub struct AlertReceiverConfig {
pub receiver_id: String, pub receiver_id: String,
pub receiver_webhook_url: Option<Url>,
pub send_resolved: bool,
} }

View File

@ -1,12 +1,12 @@
use async_trait::async_trait; use async_trait::async_trait;
use serde_json::Value;
use url::Url; use url::Url;
use crate::{ use crate::{
interpret::{InterpretError, Outcome}, interpret::{InterpretError, Outcome},
topology::{ topology::
K8sAnywhereTopology, Topology, K8sAnywhereTopology
oberservability::monitoring::{AlertReceiver, AlertReceiverConfig}, ,
},
}; };
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -28,14 +28,15 @@ pub trait DiscordWebhookReceiver {
) -> Result<Outcome, InterpretError>; ) -> Result<Outcome, InterpretError>;
} }
// trait used to generate alert manager config values impl<T: Topology + AlertManagerConfig> Monitor for KubePrometheus
pub trait AlertManagerConfig<T> {
fn get_alert_manager_config(&self) -> Result<Value, InterpretError>;
}
#[async_trait] #[async_trait]
impl<T: DiscordWebhookReceiver> AlertReceiver<T> for DiscordWebhookConfig { impl<T: DiscordWebhookReceiver> AlertManagerConfig<T> for DiscordWebhookConfig {
fn get_alert_receiver_config(&self) -> AlertReceiverConfig { fn get_alert_manager_config(&self) -> Result<Value, InterpretError>{
AlertReceiverConfig { todo!()
receiver_id: self.name.clone(),
receiver_webhook_url: Some(self.webhook_url.clone()),
send_resolved: self.send_resolved_notifications.clone(),
}
} }
} }
@ -54,3 +55,4 @@ impl DiscordWebhookReceiver for K8sAnywhereTopology {
todo!() todo!()
} }
} }