1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
mod generic;

use async_graphql::Interface;

use super::{ReceivedEventsTotal, SentEventsTotal};
use crate::event::Metric;

#[derive(Debug, Clone, Interface)]
#[graphql(
    field(name = "received_events_total", ty = "Option<ReceivedEventsTotal>"),
    field(name = "sent_events_total", ty = "Option<SentEventsTotal>")
)]
pub enum TransformMetrics {
    GenericTransformMetrics(generic::GenericTransformMetrics),
}

pub trait IntoTransformMetrics {
    fn into_transform_metrics(self, component_type: &str) -> TransformMetrics;
}

impl IntoTransformMetrics for Vec<Metric> {
    fn into_transform_metrics(self, _component_type: &str) -> TransformMetrics {
        TransformMetrics::GenericTransformMetrics(generic::GenericTransformMetrics::new(self))
    }
}