risingwave_common/telemetry/
manager.rs1use std::sync::Arc;
16
17use tokio::sync::oneshot::Sender;
18use tokio::task::JoinHandle;
19
20use super::report::{TelemetryInfoFetcher, TelemetryReportCreator, start_telemetry_reporting};
21
22pub struct TelemetryManager<F, I>
23where
24 F: TelemetryReportCreator + Send + Sync + 'static,
25 I: TelemetryInfoFetcher + Send + Sync + 'static,
26{
27 info_fetcher: Arc<I>,
28 report_creator: Arc<F>,
29}
30
31impl<F, I> TelemetryManager<F, I>
32where
33 F: TelemetryReportCreator + Send + Sync + 'static,
34 I: TelemetryInfoFetcher + Send + Sync + 'static,
35{
36 pub fn new(info_fetcher: Arc<I>, report_creator: Arc<F>) -> Self {
37 Self {
38 info_fetcher,
39 report_creator,
40 }
41 }
42
43 pub async fn start(&self) -> (JoinHandle<()>, Sender<()>) {
44 start_telemetry_reporting(self.info_fetcher.clone(), self.report_creator.clone()).await
45 }
46}