1use graphql_client::GraphQLQuery;
4
5use crate::BoxedSubscription;
6
7#[derive(GraphQLQuery, Debug, Copy, Clone)]
10#[graphql(
11 schema_path = "graphql/schema.json",
12 query_path = "graphql/subscriptions/uptime.graphql",
13 response_derives = "Debug"
14)]
15pub struct UptimeSubscription;
16
17#[derive(GraphQLQuery, Debug, Copy, Clone)]
20#[graphql(
21 schema_path = "graphql/schema.json",
22 query_path = "graphql/subscriptions/component_allocated_bytes.graphql",
23 response_derives = "Debug"
24)]
25pub struct ComponentAllocatedBytesSubscription;
26
27#[derive(GraphQLQuery, Debug, Copy, Clone)]
30#[graphql(
31 schema_path = "graphql/schema.json",
32 query_path = "graphql/subscriptions/component_received_bytes_throughputs.graphql",
33 response_derives = "Debug"
34)]
35pub struct ComponentReceivedBytesThroughputsSubscription;
36
37#[derive(GraphQLQuery, Debug, Copy, Clone)]
40#[graphql(
41 schema_path = "graphql/schema.json",
42 query_path = "graphql/subscriptions/component_received_bytes_totals.graphql",
43 response_derives = "Debug"
44)]
45pub struct ComponentReceivedBytesTotalsSubscription;
46
47#[derive(GraphQLQuery, Debug, Copy, Clone)]
50#[graphql(
51 schema_path = "graphql/schema.json",
52 query_path = "graphql/subscriptions/component_received_events_throughputs.graphql",
53 response_derives = "Debug"
54)]
55pub struct ComponentReceivedEventsThroughputsSubscription;
56
57#[derive(GraphQLQuery, Debug, Copy, Clone)]
60#[graphql(
61 schema_path = "graphql/schema.json",
62 query_path = "graphql/subscriptions/component_received_events_totals.graphql",
63 response_derives = "Debug"
64)]
65pub struct ComponentReceivedEventsTotalsSubscription;
66
67#[derive(GraphQLQuery, Debug, Copy, Clone)]
70#[graphql(
71 schema_path = "graphql/schema.json",
72 query_path = "graphql/subscriptions/component_sent_bytes_throughputs.graphql",
73 response_derives = "Debug"
74)]
75pub struct ComponentSentBytesThroughputsSubscription;
76
77#[derive(GraphQLQuery, Debug, Copy, Clone)]
80#[graphql(
81 schema_path = "graphql/schema.json",
82 query_path = "graphql/subscriptions/component_sent_bytes_totals.graphql",
83 response_derives = "Debug"
84)]
85pub struct ComponentSentBytesTotalsSubscription;
86
87#[derive(GraphQLQuery, Debug, Copy, Clone)]
90#[graphql(
91 schema_path = "graphql/schema.json",
92 query_path = "graphql/subscriptions/component_sent_events_throughputs.graphql",
93 response_derives = "Debug"
94)]
95pub struct ComponentSentEventsThroughputsSubscription;
96
97#[derive(GraphQLQuery, Debug, Copy, Clone)]
100#[graphql(
101 schema_path = "graphql/schema.json",
102 query_path = "graphql/subscriptions/component_sent_events_totals.graphql",
103 response_derives = "Debug"
104)]
105pub struct ComponentSentEventsTotalsSubscription;
106
107impl component_sent_events_totals_subscription::ComponentSentEventsTotalsSubscriptionComponentSentEventsTotals {
108 pub fn outputs(&self) -> Vec<(String, i64)> {
109 self.outputs
110 .iter()
111 .map(|output| {
112 (
113 output.output_id.clone(),
114 output
115 .sent_events_total
116 .as_ref()
117 .map(|p| p.sent_events_total as i64)
118 .unwrap_or(0),
119 )
120 })
121 .collect()
122 }
123}
124
125impl component_sent_events_throughputs_subscription::ComponentSentEventsThroughputsSubscriptionComponentSentEventsThroughputs {
126 pub fn outputs(&self) -> Vec<(String, i64)> {
127 self.outputs
128 .iter()
129 .map(|output| {
130 (
131 output.output_id.clone(),
132 output.throughput,
133 )
134 })
135 .collect()
136 }
137
138}
139
140#[derive(GraphQLQuery, Debug, Copy, Clone)]
143#[graphql(
144 schema_path = "graphql/schema.json",
145 query_path = "graphql/subscriptions/component_errors_totals.graphql",
146 response_derives = "Debug"
147)]
148pub struct ComponentErrorsTotalsSubscription;
149
150pub trait MetricsSubscriptionExt {
152 fn uptime_subscription(&self) -> crate::BoxedSubscription<UptimeSubscription>;
154
155 fn component_allocated_bytes_subscription(
157 &self,
158 interval: i64,
159 ) -> BoxedSubscription<ComponentAllocatedBytesSubscription>;
160
161 fn component_received_bytes_totals_subscription(
163 &self,
164 interval: i64,
165 ) -> crate::BoxedSubscription<ComponentReceivedBytesTotalsSubscription>;
166
167 fn component_received_bytes_throughputs_subscription(
169 &self,
170 interval: i64,
171 ) -> crate::BoxedSubscription<ComponentReceivedBytesThroughputsSubscription>;
172
173 fn component_received_events_totals_subscription(
175 &self,
176 interval: i64,
177 ) -> crate::BoxedSubscription<ComponentReceivedEventsTotalsSubscription>;
178
179 fn component_received_events_throughputs_subscription(
181 &self,
182 interval: i64,
183 ) -> crate::BoxedSubscription<ComponentReceivedEventsThroughputsSubscription>;
184
185 fn component_sent_bytes_totals_subscription(
187 &self,
188 interval: i64,
189 ) -> crate::BoxedSubscription<ComponentSentBytesTotalsSubscription>;
190
191 fn component_sent_bytes_throughputs_subscription(
193 &self,
194 interval: i64,
195 ) -> crate::BoxedSubscription<ComponentSentBytesThroughputsSubscription>;
196
197 fn component_sent_events_totals_subscription(
199 &self,
200 interval: i64,
201 ) -> crate::BoxedSubscription<ComponentSentEventsTotalsSubscription>;
202
203 fn component_sent_events_throughputs_subscription(
205 &self,
206 interval: i64,
207 ) -> crate::BoxedSubscription<ComponentSentEventsThroughputsSubscription>;
208
209 fn component_errors_totals_subscription(
210 &self,
211 interval: i64,
212 ) -> crate::BoxedSubscription<ComponentErrorsTotalsSubscription>;
213}
214
215impl MetricsSubscriptionExt for crate::SubscriptionClient {
216 fn uptime_subscription(&self) -> BoxedSubscription<UptimeSubscription> {
218 let request_body = UptimeSubscription::build_query(uptime_subscription::Variables);
219
220 self.start::<UptimeSubscription>(&request_body)
221 }
222
223 fn component_allocated_bytes_subscription(
225 &self,
226 interval: i64,
227 ) -> BoxedSubscription<ComponentAllocatedBytesSubscription> {
228 let request_body = ComponentAllocatedBytesSubscription::build_query(
229 component_allocated_bytes_subscription::Variables { interval },
230 );
231
232 self.start::<ComponentAllocatedBytesSubscription>(&request_body)
233 }
234
235 fn component_received_bytes_totals_subscription(
237 &self,
238 interval: i64,
239 ) -> BoxedSubscription<ComponentReceivedBytesTotalsSubscription> {
240 let request_body = ComponentReceivedBytesTotalsSubscription::build_query(
241 component_received_bytes_totals_subscription::Variables { interval },
242 );
243
244 self.start::<ComponentReceivedBytesTotalsSubscription>(&request_body)
245 }
246
247 fn component_received_bytes_throughputs_subscription(
249 &self,
250 interval: i64,
251 ) -> BoxedSubscription<ComponentReceivedBytesThroughputsSubscription> {
252 let request_body = ComponentReceivedBytesThroughputsSubscription::build_query(
253 component_received_bytes_throughputs_subscription::Variables { interval },
254 );
255
256 self.start::<ComponentReceivedBytesThroughputsSubscription>(&request_body)
257 }
258
259 fn component_received_events_totals_subscription(
261 &self,
262 interval: i64,
263 ) -> BoxedSubscription<ComponentReceivedEventsTotalsSubscription> {
264 let request_body = ComponentReceivedEventsTotalsSubscription::build_query(
265 component_received_events_totals_subscription::Variables { interval },
266 );
267
268 self.start::<ComponentReceivedEventsTotalsSubscription>(&request_body)
269 }
270
271 fn component_received_events_throughputs_subscription(
273 &self,
274 interval: i64,
275 ) -> BoxedSubscription<ComponentReceivedEventsThroughputsSubscription> {
276 let request_body = ComponentReceivedEventsThroughputsSubscription::build_query(
277 component_received_events_throughputs_subscription::Variables { interval },
278 );
279
280 self.start::<ComponentReceivedEventsThroughputsSubscription>(&request_body)
281 }
282
283 fn component_sent_bytes_totals_subscription(
285 &self,
286 interval: i64,
287 ) -> BoxedSubscription<ComponentSentBytesTotalsSubscription> {
288 let request_body = ComponentSentBytesTotalsSubscription::build_query(
289 component_sent_bytes_totals_subscription::Variables { interval },
290 );
291
292 self.start::<ComponentSentBytesTotalsSubscription>(&request_body)
293 }
294
295 fn component_sent_bytes_throughputs_subscription(
297 &self,
298 interval: i64,
299 ) -> BoxedSubscription<ComponentSentBytesThroughputsSubscription> {
300 let request_body = ComponentSentBytesThroughputsSubscription::build_query(
301 component_sent_bytes_throughputs_subscription::Variables { interval },
302 );
303
304 self.start::<ComponentSentBytesThroughputsSubscription>(&request_body)
305 }
306
307 fn component_sent_events_totals_subscription(
309 &self,
310 interval: i64,
311 ) -> crate::BoxedSubscription<ComponentSentEventsTotalsSubscription> {
312 let request_body = ComponentSentEventsTotalsSubscription::build_query(
313 component_sent_events_totals_subscription::Variables { interval },
314 );
315
316 self.start::<ComponentSentEventsTotalsSubscription>(&request_body)
317 }
318
319 fn component_sent_events_throughputs_subscription(
321 &self,
322 interval: i64,
323 ) -> crate::BoxedSubscription<ComponentSentEventsThroughputsSubscription> {
324 let request_body = ComponentSentEventsThroughputsSubscription::build_query(
325 component_sent_events_throughputs_subscription::Variables { interval },
326 );
327
328 self.start::<ComponentSentEventsThroughputsSubscription>(&request_body)
329 }
330
331 fn component_errors_totals_subscription(
332 &self,
333 interval: i64,
334 ) -> BoxedSubscription<ComponentErrorsTotalsSubscription> {
335 let request_body = ComponentErrorsTotalsSubscription::build_query(
336 component_errors_totals_subscription::Variables { interval },
337 );
338
339 self.start::<ComponentErrorsTotalsSubscription>(&request_body)
340 }
341}