use graphql_client::GraphQLQuery;
use crate::BoxedSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/uptime.graphql",
response_derives = "Debug"
)]
pub struct UptimeSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_allocated_bytes.graphql",
response_derives = "Debug"
)]
pub struct ComponentAllocatedBytesSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_received_bytes_throughputs.graphql",
response_derives = "Debug"
)]
pub struct ComponentReceivedBytesThroughputsSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_received_bytes_totals.graphql",
response_derives = "Debug"
)]
pub struct ComponentReceivedBytesTotalsSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_received_events_throughputs.graphql",
response_derives = "Debug"
)]
pub struct ComponentReceivedEventsThroughputsSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_received_events_totals.graphql",
response_derives = "Debug"
)]
pub struct ComponentReceivedEventsTotalsSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_sent_bytes_throughputs.graphql",
response_derives = "Debug"
)]
pub struct ComponentSentBytesThroughputsSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_sent_bytes_totals.graphql",
response_derives = "Debug"
)]
pub struct ComponentSentBytesTotalsSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_sent_events_throughputs.graphql",
response_derives = "Debug"
)]
pub struct ComponentSentEventsThroughputsSubscription;
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_sent_events_totals.graphql",
response_derives = "Debug"
)]
pub struct ComponentSentEventsTotalsSubscription;
impl component_sent_events_totals_subscription::ComponentSentEventsTotalsSubscriptionComponentSentEventsTotals {
pub fn outputs(&self) -> Vec<(String, i64)> {
self.outputs
.iter()
.map(|output| {
(
output.output_id.clone(),
output
.sent_events_total
.as_ref()
.map(|p| p.sent_events_total as i64)
.unwrap_or(0),
)
})
.collect()
}
}
impl component_sent_events_throughputs_subscription::ComponentSentEventsThroughputsSubscriptionComponentSentEventsThroughputs {
pub fn outputs(&self) -> Vec<(String, i64)> {
self.outputs
.iter()
.map(|output| {
(
output.output_id.clone(),
output.throughput,
)
})
.collect()
}
}
#[derive(GraphQLQuery, Debug, Copy, Clone)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/subscriptions/component_errors_totals.graphql",
response_derives = "Debug"
)]
pub struct ComponentErrorsTotalsSubscription;
pub trait MetricsSubscriptionExt {
fn uptime_subscription(&self) -> crate::BoxedSubscription<UptimeSubscription>;
fn component_allocated_bytes_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentAllocatedBytesSubscription>;
fn component_received_bytes_totals_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentReceivedBytesTotalsSubscription>;
fn component_received_bytes_throughputs_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentReceivedBytesThroughputsSubscription>;
fn component_received_events_totals_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentReceivedEventsTotalsSubscription>;
fn component_received_events_throughputs_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentReceivedEventsThroughputsSubscription>;
fn component_sent_bytes_totals_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentSentBytesTotalsSubscription>;
fn component_sent_bytes_throughputs_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentSentBytesThroughputsSubscription>;
fn component_sent_events_totals_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentSentEventsTotalsSubscription>;
fn component_sent_events_throughputs_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentSentEventsThroughputsSubscription>;
fn component_errors_totals_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentErrorsTotalsSubscription>;
}
impl MetricsSubscriptionExt for crate::SubscriptionClient {
fn uptime_subscription(&self) -> BoxedSubscription<UptimeSubscription> {
let request_body = UptimeSubscription::build_query(uptime_subscription::Variables);
self.start::<UptimeSubscription>(&request_body)
}
fn component_allocated_bytes_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentAllocatedBytesSubscription> {
let request_body = ComponentAllocatedBytesSubscription::build_query(
component_allocated_bytes_subscription::Variables { interval },
);
self.start::<ComponentAllocatedBytesSubscription>(&request_body)
}
fn component_received_bytes_totals_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentReceivedBytesTotalsSubscription> {
let request_body = ComponentReceivedBytesTotalsSubscription::build_query(
component_received_bytes_totals_subscription::Variables { interval },
);
self.start::<ComponentReceivedBytesTotalsSubscription>(&request_body)
}
fn component_received_bytes_throughputs_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentReceivedBytesThroughputsSubscription> {
let request_body = ComponentReceivedBytesThroughputsSubscription::build_query(
component_received_bytes_throughputs_subscription::Variables { interval },
);
self.start::<ComponentReceivedBytesThroughputsSubscription>(&request_body)
}
fn component_received_events_totals_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentReceivedEventsTotalsSubscription> {
let request_body = ComponentReceivedEventsTotalsSubscription::build_query(
component_received_events_totals_subscription::Variables { interval },
);
self.start::<ComponentReceivedEventsTotalsSubscription>(&request_body)
}
fn component_received_events_throughputs_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentReceivedEventsThroughputsSubscription> {
let request_body = ComponentReceivedEventsThroughputsSubscription::build_query(
component_received_events_throughputs_subscription::Variables { interval },
);
self.start::<ComponentReceivedEventsThroughputsSubscription>(&request_body)
}
fn component_sent_bytes_totals_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentSentBytesTotalsSubscription> {
let request_body = ComponentSentBytesTotalsSubscription::build_query(
component_sent_bytes_totals_subscription::Variables { interval },
);
self.start::<ComponentSentBytesTotalsSubscription>(&request_body)
}
fn component_sent_bytes_throughputs_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentSentBytesThroughputsSubscription> {
let request_body = ComponentSentBytesThroughputsSubscription::build_query(
component_sent_bytes_throughputs_subscription::Variables { interval },
);
self.start::<ComponentSentBytesThroughputsSubscription>(&request_body)
}
fn component_sent_events_totals_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentSentEventsTotalsSubscription> {
let request_body = ComponentSentEventsTotalsSubscription::build_query(
component_sent_events_totals_subscription::Variables { interval },
);
self.start::<ComponentSentEventsTotalsSubscription>(&request_body)
}
fn component_sent_events_throughputs_subscription(
&self,
interval: i64,
) -> crate::BoxedSubscription<ComponentSentEventsThroughputsSubscription> {
let request_body = ComponentSentEventsThroughputsSubscription::build_query(
component_sent_events_throughputs_subscription::Variables { interval },
);
self.start::<ComponentSentEventsThroughputsSubscription>(&request_body)
}
fn component_errors_totals_subscription(
&self,
interval: i64,
) -> BoxedSubscription<ComponentErrorsTotalsSubscription> {
let request_body = ComponentErrorsTotalsSubscription::build_query(
component_errors_totals_subscription::Variables { interval },
);
self.start::<ComponentErrorsTotalsSubscription>(&request_body)
}
}