feat: impl clone_box for ScrapeTarget<CRDPrometheus>
All checks were successful
Run Check Script / check (pull_request) Successful in 1m25s

This commit is contained in:
Jean-Gabriel Gill-Couture 2025-10-24 11:39:27 -04:00
parent de761cf538
commit 609d7acb5d
4 changed files with 14 additions and 2 deletions

View File

@ -87,4 +87,5 @@ pub trait AlertRule<S: AlertSender>: std::fmt::Debug + Send + Sync {
#[async_trait] #[async_trait]
pub trait ScrapeTarget<S: AlertSender>: std::fmt::Debug + Send + Sync { pub trait ScrapeTarget<S: AlertSender>: std::fmt::Debug + Send + Sync {
async fn install(&self, sender: &S) -> Result<Outcome, InterpretError>; async fn install(&self, sender: &S) -> Result<Outcome, InterpretError>;
fn clone_box(&self) -> Box<dyn ScrapeTarget<S>>;
} }

View File

@ -15,7 +15,7 @@ use crate::{
score::Score, score::Score,
topology::{ topology::{
K8sclient, Topology, K8sclient, Topology,
oberservability::monitoring::{AlertReceiver, AlertingInterpret}, oberservability::monitoring::{AlertReceiver, AlertingInterpret, ScrapeTarget},
}, },
}; };
@ -35,6 +35,7 @@ impl<T: Topology + PrometheusMonitoring<CRDPrometheus> + K8sclient + Grafana> Sc
sender: self.sender.clone(), sender: self.sender.clone(),
receivers: self.receivers.clone(), receivers: self.receivers.clone(),
rules: vec![], rules: vec![],
scrape_targets: None,
}) })
} }

View File

@ -18,7 +18,7 @@ use crate::{
K8sclient, Topology, K8sclient, Topology,
installable::Installable, installable::Installable,
k8s::K8sClient, k8s::K8sClient,
oberservability::monitoring::{AlertReceiver, AlertSender}, oberservability::monitoring::{AlertReceiver, AlertSender, ScrapeTarget},
}, },
}; };
@ -54,6 +54,12 @@ impl Clone for Box<dyn AlertReceiver<CRDPrometheus>> {
} }
} }
impl Clone for Box<dyn ScrapeTarget<CRDPrometheus>> {
fn clone(&self) -> Self {
self.clone_box()
}
}
impl Serialize for Box<dyn AlertReceiver<CRDPrometheus>> { impl Serialize for Box<dyn AlertReceiver<CRDPrometheus>> {
fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, _serializer: S) -> Result<S::Ok, S::Error>
where where

View File

@ -73,4 +73,8 @@ impl ScrapeTarget<CRDPrometheus> for Server {
self.name.clone() self.name.clone()
))) )))
} }
fn clone_box(&self) -> Box<dyn ScrapeTarget<CRDPrometheus>> {
Box::new(self.clone())
}
} }