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 dyn_clone::DynClone;
use std::fmt::Debug;
use url::Url;
@ -9,7 +8,7 @@ use crate::interpret::InterpretError;
use crate::{interpret::Outcome, topology::Topology};
/// 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
/// monitoring data, enabling consistent processing regardless of the underlying data source.
#[async_trait]
@ -17,23 +16,16 @@ pub trait Monitor<T: Topology>: Debug + Send + Sync {
async fn deploy_monitor(
&self,
topology: &T,
alert_receivers: Vec<Box<dyn AlertReceiver<T>>>,
alert_receivers: Vec<AlertReceiver>,
) -> Result<Outcome, InterpretError>;
async fn delete_monitor(
&self,
topolgy: &T,
alert_receivers: Vec<Box<dyn AlertReceiver<T>>>,
alert_receivers: Vec<AlertReceiver>,
) -> Result<Outcome, InterpretError>;
}
#[async_trait]
pub trait AlertReceiver<T>: Debug + DynClone + Send + Sync {
fn get_alert_receiver_config(&self) -> AlertReceiverConfig;
}
pub struct AlertReceiverConfig {
pub struct AlertReceiver {
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 serde_json::Value;
use url::Url;
use crate::{
interpret::{InterpretError, Outcome},
topology::{
K8sAnywhereTopology, Topology,
oberservability::monitoring::{AlertReceiver, AlertReceiverConfig},
},
topology::
K8sAnywhereTopology
,
};
#[derive(Debug, Clone)]
@ -28,14 +28,15 @@ pub trait DiscordWebhookReceiver {
) -> 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]
impl<T: DiscordWebhookReceiver> AlertReceiver<T> for DiscordWebhookConfig {
fn get_alert_receiver_config(&self) -> AlertReceiverConfig {
AlertReceiverConfig {
receiver_id: self.name.clone(),
receiver_webhook_url: Some(self.webhook_url.clone()),
send_resolved: self.send_resolved_notifications.clone(),
}
impl<T: DiscordWebhookReceiver> AlertManagerConfig<T> for DiscordWebhookConfig {
fn get_alert_manager_config(&self) -> Result<Value, InterpretError>{
todo!()
}
}
@ -54,3 +55,4 @@ impl DiscordWebhookReceiver for K8sAnywhereTopology {
todo!()
}
}