1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct RequestActiveConnections {
4 #[prost(string, optional, tag = "2")]
5 pub pod_ip: ::core::option::Option<::prost::alloc::string::String>,
6}
7#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
8pub struct ConnectionEvent {
9 #[prost(string, tag = "1")]
10 pub event_id: ::prost::alloc::string::String,
11 #[prost(string, tag = "2")]
13 pub src_ip_port: ::prost::alloc::string::String,
14 #[prost(string, tag = "3")]
16 pub dst_ip_port: ::prost::alloc::string::String,
17}
18#[derive(Clone, PartialEq, ::prost::Message)]
19pub struct ActiveConnectionResponse {
20 #[prost(string, tag = "1")]
21 pub status: ::prost::alloc::string::String,
22 #[prost(message, repeated, tag = "2")]
24 pub events: ::prost::alloc::vec::Vec<ConnectionEvent>,
25}
26#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
27pub struct LatencyMetric {
28 #[prost(uint64, tag = "1")]
30 pub delta_us: u64,
31 #[prost(uint64, tag = "2")]
33 pub timestamp_us: u64,
34 #[prost(uint32, tag = "3")]
36 pub tgid: u32,
37 #[prost(string, tag = "4")]
39 pub process_name: ::prost::alloc::string::String,
40 #[prost(uint32, tag = "5")]
42 pub local_port: u32,
43 #[prost(uint32, tag = "6")]
45 pub remote_port: u32,
46 #[prost(uint32, tag = "7")]
48 pub address_family: u32,
49 #[prost(string, tag = "8")]
51 pub src_address_v4: ::prost::alloc::string::String,
52 #[prost(string, tag = "9")]
54 pub dst_address_v4: ::prost::alloc::string::String,
55 #[prost(string, tag = "10")]
57 pub src_address_v6: ::prost::alloc::string::String,
58 #[prost(string, tag = "11")]
60 pub dst_address_v6: ::prost::alloc::string::String,
61}
62#[derive(Clone, PartialEq, ::prost::Message)]
63pub struct LatencyMetricsResponse {
64 #[prost(string, tag = "1")]
65 pub status: ::prost::alloc::string::String,
66 #[prost(message, repeated, tag = "2")]
67 pub metrics: ::prost::alloc::vec::Vec<LatencyMetric>,
68 #[prost(uint32, tag = "3")]
69 pub total_count: u32,
70 #[prost(double, tag = "4")]
72 pub average_latency_us: f64,
73 #[prost(double, tag = "5")]
75 pub min_latency_us: f64,
76 #[prost(double, tag = "6")]
78 pub max_latency_us: f64,
79}
80#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
81pub struct DroppedPacketMetric {
82 #[prost(uint32, tag = "1")]
84 pub tgid: u32,
85 #[prost(string, tag = "2")]
87 pub process_name: ::prost::alloc::string::String,
88 #[prost(int32, tag = "3")]
90 pub sk_drops: i32,
91 #[prost(int32, tag = "4")]
93 pub sk_err: i32,
94 #[prost(int32, tag = "5")]
96 pub sk_err_soft: i32,
97 #[prost(uint32, tag = "6")]
99 pub sk_backlog_len: u32,
100 #[prost(int32, tag = "7")]
102 pub sk_wmem_queued: i32,
103 #[prost(int32, tag = "8")]
105 pub sk_rcvbuf: i32,
106 #[prost(uint32, tag = "9")]
108 pub sk_ack_backlog: u32,
109 #[prost(uint64, tag = "10")]
111 pub timestamp_us: u64,
112}
113#[derive(Clone, PartialEq, ::prost::Message)]
114pub struct DroppedPacketsResponse {
115 #[prost(string, tag = "1")]
116 pub status: ::prost::alloc::string::String,
117 #[prost(message, repeated, tag = "2")]
118 pub metrics: ::prost::alloc::vec::Vec<DroppedPacketMetric>,
119 #[prost(uint32, tag = "3")]
121 pub total_drops: u32,
122}
123#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
124pub struct AddIpToBlocklistRequest {
125 #[prost(string, optional, tag = "1")]
126 pub ip: ::core::option::Option<::prost::alloc::string::String>,
127}
128#[derive(Clone, PartialEq, ::prost::Message)]
129pub struct BlocklistResponse {
130 #[prost(string, tag = "1")]
131 pub status: ::prost::alloc::string::String,
132 #[prost(map = "string, string", tag = "2")]
133 pub events: ::std::collections::HashMap<
134 ::prost::alloc::string::String,
135 ::prost::alloc::string::String,
136 >,
137}
138#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
139pub struct RmIpFromBlocklistRequest {
140 #[prost(string, tag = "1")]
141 pub ip: ::prost::alloc::string::String,
142}
143#[derive(Clone, PartialEq, ::prost::Message)]
144pub struct RmIpFromBlocklistResponse {
145 #[prost(string, tag = "1")]
146 pub status: ::prost::alloc::string::String,
147 #[prost(map = "string, string", tag = "2")]
148 pub events: ::std::collections::HashMap<
149 ::prost::alloc::string::String,
150 ::prost::alloc::string::String,
151 >,
152}
153pub mod agent_client {
155 #![allow(
156 unused_variables,
157 dead_code,
158 missing_docs,
159 clippy::wildcard_imports,
160 clippy::let_unit_value,
161 )]
162 use tonic::codegen::*;
163 use tonic::codegen::http::Uri;
164 #[derive(Debug, Clone)]
166 pub struct AgentClient<T> {
167 inner: tonic::client::Grpc<T>,
168 }
169 impl AgentClient<tonic::transport::Channel> {
170 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
172 where
173 D: TryInto<tonic::transport::Endpoint>,
174 D::Error: Into<StdError>,
175 {
176 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
177 Ok(Self::new(conn))
178 }
179 }
180 impl<T> AgentClient<T>
181 where
182 T: tonic::client::GrpcService<tonic::body::Body>,
183 T::Error: Into<StdError>,
184 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
185 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
186 {
187 pub fn new(inner: T) -> Self {
188 let inner = tonic::client::Grpc::new(inner);
189 Self { inner }
190 }
191 pub fn with_origin(inner: T, origin: Uri) -> Self {
192 let inner = tonic::client::Grpc::with_origin(inner, origin);
193 Self { inner }
194 }
195 pub fn with_interceptor<F>(
196 inner: T,
197 interceptor: F,
198 ) -> AgentClient<InterceptedService<T, F>>
199 where
200 F: tonic::service::Interceptor,
201 T::ResponseBody: Default,
202 T: tonic::codegen::Service<
203 http::Request<tonic::body::Body>,
204 Response = http::Response<
205 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
206 >,
207 >,
208 <T as tonic::codegen::Service<
209 http::Request<tonic::body::Body>,
210 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
211 {
212 AgentClient::new(InterceptedService::new(inner, interceptor))
213 }
214 #[must_use]
219 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
220 self.inner = self.inner.send_compressed(encoding);
221 self
222 }
223 #[must_use]
225 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
226 self.inner = self.inner.accept_compressed(encoding);
227 self
228 }
229 #[must_use]
233 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
234 self.inner = self.inner.max_decoding_message_size(limit);
235 self
236 }
237 #[must_use]
241 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
242 self.inner = self.inner.max_encoding_message_size(limit);
243 self
244 }
245 pub async fn active_connections(
247 &mut self,
248 request: impl tonic::IntoRequest<super::RequestActiveConnections>,
249 ) -> std::result::Result<
250 tonic::Response<super::ActiveConnectionResponse>,
251 tonic::Status,
252 > {
253 self.inner
254 .ready()
255 .await
256 .map_err(|e| {
257 tonic::Status::unknown(
258 format!("Service was not ready: {}", e.into()),
259 )
260 })?;
261 let codec = tonic_prost::ProstCodec::default();
262 let path = http::uri::PathAndQuery::from_static(
263 "/agent.Agent/ActiveConnections",
264 );
265 let mut req = request.into_request();
266 req.extensions_mut()
267 .insert(GrpcMethod::new("agent.Agent", "ActiveConnections"));
268 self.inner.unary(req, path, codec).await
269 }
270 pub async fn add_ip_to_blocklist(
272 &mut self,
273 request: impl tonic::IntoRequest<super::AddIpToBlocklistRequest>,
274 ) -> std::result::Result<
275 tonic::Response<super::BlocklistResponse>,
276 tonic::Status,
277 > {
278 self.inner
279 .ready()
280 .await
281 .map_err(|e| {
282 tonic::Status::unknown(
283 format!("Service was not ready: {}", e.into()),
284 )
285 })?;
286 let codec = tonic_prost::ProstCodec::default();
287 let path = http::uri::PathAndQuery::from_static(
288 "/agent.Agent/AddIpToBlocklist",
289 );
290 let mut req = request.into_request();
291 req.extensions_mut()
292 .insert(GrpcMethod::new("agent.Agent", "AddIpToBlocklist"));
293 self.inner.unary(req, path, codec).await
294 }
295 pub async fn check_blocklist(
296 &mut self,
297 request: impl tonic::IntoRequest<()>,
298 ) -> std::result::Result<
299 tonic::Response<super::BlocklistResponse>,
300 tonic::Status,
301 > {
302 self.inner
303 .ready()
304 .await
305 .map_err(|e| {
306 tonic::Status::unknown(
307 format!("Service was not ready: {}", e.into()),
308 )
309 })?;
310 let codec = tonic_prost::ProstCodec::default();
311 let path = http::uri::PathAndQuery::from_static(
312 "/agent.Agent/CheckBlocklist",
313 );
314 let mut req = request.into_request();
315 req.extensions_mut()
316 .insert(GrpcMethod::new("agent.Agent", "CheckBlocklist"));
317 self.inner.unary(req, path, codec).await
318 }
319 pub async fn rm_ip_from_blocklist(
321 &mut self,
322 request: impl tonic::IntoRequest<super::RmIpFromBlocklistRequest>,
323 ) -> std::result::Result<
324 tonic::Response<super::RmIpFromBlocklistResponse>,
325 tonic::Status,
326 > {
327 self.inner
328 .ready()
329 .await
330 .map_err(|e| {
331 tonic::Status::unknown(
332 format!("Service was not ready: {}", e.into()),
333 )
334 })?;
335 let codec = tonic_prost::ProstCodec::default();
336 let path = http::uri::PathAndQuery::from_static(
337 "/agent.Agent/RmIpFromBlocklist",
338 );
339 let mut req = request.into_request();
340 req.extensions_mut()
341 .insert(GrpcMethod::new("agent.Agent", "RmIpFromBlocklist"));
342 self.inner.unary(req, path, codec).await
343 }
344 pub async fn get_latency_metrics(
346 &mut self,
347 request: impl tonic::IntoRequest<()>,
348 ) -> std::result::Result<
349 tonic::Response<super::LatencyMetricsResponse>,
350 tonic::Status,
351 > {
352 self.inner
353 .ready()
354 .await
355 .map_err(|e| {
356 tonic::Status::unknown(
357 format!("Service was not ready: {}", e.into()),
358 )
359 })?;
360 let codec = tonic_prost::ProstCodec::default();
361 let path = http::uri::PathAndQuery::from_static(
362 "/agent.Agent/GetLatencyMetrics",
363 );
364 let mut req = request.into_request();
365 req.extensions_mut()
366 .insert(GrpcMethod::new("agent.Agent", "GetLatencyMetrics"));
367 self.inner.unary(req, path, codec).await
368 }
369 pub async fn get_dropped_packets_metrics(
371 &mut self,
372 request: impl tonic::IntoRequest<()>,
373 ) -> std::result::Result<
374 tonic::Response<super::DroppedPacketsResponse>,
375 tonic::Status,
376 > {
377 self.inner
378 .ready()
379 .await
380 .map_err(|e| {
381 tonic::Status::unknown(
382 format!("Service was not ready: {}", e.into()),
383 )
384 })?;
385 let codec = tonic_prost::ProstCodec::default();
386 let path = http::uri::PathAndQuery::from_static(
387 "/agent.Agent/GetDroppedPacketsMetrics",
388 );
389 let mut req = request.into_request();
390 req.extensions_mut()
391 .insert(GrpcMethod::new("agent.Agent", "GetDroppedPacketsMetrics"));
392 self.inner.unary(req, path, codec).await
393 }
394 }
395}
396pub mod agent_server {
398 #![allow(
399 unused_variables,
400 dead_code,
401 missing_docs,
402 clippy::wildcard_imports,
403 clippy::let_unit_value,
404 )]
405 use tonic::codegen::*;
406 #[async_trait]
408 pub trait Agent: std::marker::Send + std::marker::Sync + 'static {
409 async fn active_connections(
411 &self,
412 request: tonic::Request<super::RequestActiveConnections>,
413 ) -> std::result::Result<
414 tonic::Response<super::ActiveConnectionResponse>,
415 tonic::Status,
416 >;
417 async fn add_ip_to_blocklist(
419 &self,
420 request: tonic::Request<super::AddIpToBlocklistRequest>,
421 ) -> std::result::Result<
422 tonic::Response<super::BlocklistResponse>,
423 tonic::Status,
424 >;
425 async fn check_blocklist(
426 &self,
427 request: tonic::Request<()>,
428 ) -> std::result::Result<
429 tonic::Response<super::BlocklistResponse>,
430 tonic::Status,
431 >;
432 async fn rm_ip_from_blocklist(
434 &self,
435 request: tonic::Request<super::RmIpFromBlocklistRequest>,
436 ) -> std::result::Result<
437 tonic::Response<super::RmIpFromBlocklistResponse>,
438 tonic::Status,
439 >;
440 async fn get_latency_metrics(
442 &self,
443 request: tonic::Request<()>,
444 ) -> std::result::Result<
445 tonic::Response<super::LatencyMetricsResponse>,
446 tonic::Status,
447 >;
448 async fn get_dropped_packets_metrics(
450 &self,
451 request: tonic::Request<()>,
452 ) -> std::result::Result<
453 tonic::Response<super::DroppedPacketsResponse>,
454 tonic::Status,
455 >;
456 }
457 #[derive(Debug)]
459 pub struct AgentServer<T> {
460 inner: Arc<T>,
461 accept_compression_encodings: EnabledCompressionEncodings,
462 send_compression_encodings: EnabledCompressionEncodings,
463 max_decoding_message_size: Option<usize>,
464 max_encoding_message_size: Option<usize>,
465 }
466 impl<T> AgentServer<T> {
467 pub fn new(inner: T) -> Self {
468 Self::from_arc(Arc::new(inner))
469 }
470 pub fn from_arc(inner: Arc<T>) -> Self {
471 Self {
472 inner,
473 accept_compression_encodings: Default::default(),
474 send_compression_encodings: Default::default(),
475 max_decoding_message_size: None,
476 max_encoding_message_size: None,
477 }
478 }
479 pub fn with_interceptor<F>(
480 inner: T,
481 interceptor: F,
482 ) -> InterceptedService<Self, F>
483 where
484 F: tonic::service::Interceptor,
485 {
486 InterceptedService::new(Self::new(inner), interceptor)
487 }
488 #[must_use]
490 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
491 self.accept_compression_encodings.enable(encoding);
492 self
493 }
494 #[must_use]
496 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
497 self.send_compression_encodings.enable(encoding);
498 self
499 }
500 #[must_use]
504 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
505 self.max_decoding_message_size = Some(limit);
506 self
507 }
508 #[must_use]
512 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
513 self.max_encoding_message_size = Some(limit);
514 self
515 }
516 }
517 impl<T, B> tonic::codegen::Service<http::Request<B>> for AgentServer<T>
518 where
519 T: Agent,
520 B: Body + std::marker::Send + 'static,
521 B::Error: Into<StdError> + std::marker::Send + 'static,
522 {
523 type Response = http::Response<tonic::body::Body>;
524 type Error = std::convert::Infallible;
525 type Future = BoxFuture<Self::Response, Self::Error>;
526 fn poll_ready(
527 &mut self,
528 _cx: &mut Context<'_>,
529 ) -> Poll<std::result::Result<(), Self::Error>> {
530 Poll::Ready(Ok(()))
531 }
532 fn call(&mut self, req: http::Request<B>) -> Self::Future {
533 match req.uri().path() {
534 "/agent.Agent/ActiveConnections" => {
535 #[allow(non_camel_case_types)]
536 struct ActiveConnectionsSvc<T: Agent>(pub Arc<T>);
537 impl<
538 T: Agent,
539 > tonic::server::UnaryService<super::RequestActiveConnections>
540 for ActiveConnectionsSvc<T> {
541 type Response = super::ActiveConnectionResponse;
542 type Future = BoxFuture<
543 tonic::Response<Self::Response>,
544 tonic::Status,
545 >;
546 fn call(
547 &mut self,
548 request: tonic::Request<super::RequestActiveConnections>,
549 ) -> Self::Future {
550 let inner = Arc::clone(&self.0);
551 let fut = async move {
552 <T as Agent>::active_connections(&inner, request).await
553 };
554 Box::pin(fut)
555 }
556 }
557 let accept_compression_encodings = self.accept_compression_encodings;
558 let send_compression_encodings = self.send_compression_encodings;
559 let max_decoding_message_size = self.max_decoding_message_size;
560 let max_encoding_message_size = self.max_encoding_message_size;
561 let inner = self.inner.clone();
562 let fut = async move {
563 let method = ActiveConnectionsSvc(inner);
564 let codec = tonic_prost::ProstCodec::default();
565 let mut grpc = tonic::server::Grpc::new(codec)
566 .apply_compression_config(
567 accept_compression_encodings,
568 send_compression_encodings,
569 )
570 .apply_max_message_size_config(
571 max_decoding_message_size,
572 max_encoding_message_size,
573 );
574 let res = grpc.unary(method, req).await;
575 Ok(res)
576 };
577 Box::pin(fut)
578 }
579 "/agent.Agent/AddIpToBlocklist" => {
580 #[allow(non_camel_case_types)]
581 struct AddIpToBlocklistSvc<T: Agent>(pub Arc<T>);
582 impl<
583 T: Agent,
584 > tonic::server::UnaryService<super::AddIpToBlocklistRequest>
585 for AddIpToBlocklistSvc<T> {
586 type Response = super::BlocklistResponse;
587 type Future = BoxFuture<
588 tonic::Response<Self::Response>,
589 tonic::Status,
590 >;
591 fn call(
592 &mut self,
593 request: tonic::Request<super::AddIpToBlocklistRequest>,
594 ) -> Self::Future {
595 let inner = Arc::clone(&self.0);
596 let fut = async move {
597 <T as Agent>::add_ip_to_blocklist(&inner, request).await
598 };
599 Box::pin(fut)
600 }
601 }
602 let accept_compression_encodings = self.accept_compression_encodings;
603 let send_compression_encodings = self.send_compression_encodings;
604 let max_decoding_message_size = self.max_decoding_message_size;
605 let max_encoding_message_size = self.max_encoding_message_size;
606 let inner = self.inner.clone();
607 let fut = async move {
608 let method = AddIpToBlocklistSvc(inner);
609 let codec = tonic_prost::ProstCodec::default();
610 let mut grpc = tonic::server::Grpc::new(codec)
611 .apply_compression_config(
612 accept_compression_encodings,
613 send_compression_encodings,
614 )
615 .apply_max_message_size_config(
616 max_decoding_message_size,
617 max_encoding_message_size,
618 );
619 let res = grpc.unary(method, req).await;
620 Ok(res)
621 };
622 Box::pin(fut)
623 }
624 "/agent.Agent/CheckBlocklist" => {
625 #[allow(non_camel_case_types)]
626 struct CheckBlocklistSvc<T: Agent>(pub Arc<T>);
627 impl<T: Agent> tonic::server::UnaryService<()>
628 for CheckBlocklistSvc<T> {
629 type Response = super::BlocklistResponse;
630 type Future = BoxFuture<
631 tonic::Response<Self::Response>,
632 tonic::Status,
633 >;
634 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
635 let inner = Arc::clone(&self.0);
636 let fut = async move {
637 <T as Agent>::check_blocklist(&inner, request).await
638 };
639 Box::pin(fut)
640 }
641 }
642 let accept_compression_encodings = self.accept_compression_encodings;
643 let send_compression_encodings = self.send_compression_encodings;
644 let max_decoding_message_size = self.max_decoding_message_size;
645 let max_encoding_message_size = self.max_encoding_message_size;
646 let inner = self.inner.clone();
647 let fut = async move {
648 let method = CheckBlocklistSvc(inner);
649 let codec = tonic_prost::ProstCodec::default();
650 let mut grpc = tonic::server::Grpc::new(codec)
651 .apply_compression_config(
652 accept_compression_encodings,
653 send_compression_encodings,
654 )
655 .apply_max_message_size_config(
656 max_decoding_message_size,
657 max_encoding_message_size,
658 );
659 let res = grpc.unary(method, req).await;
660 Ok(res)
661 };
662 Box::pin(fut)
663 }
664 "/agent.Agent/RmIpFromBlocklist" => {
665 #[allow(non_camel_case_types)]
666 struct RmIpFromBlocklistSvc<T: Agent>(pub Arc<T>);
667 impl<
668 T: Agent,
669 > tonic::server::UnaryService<super::RmIpFromBlocklistRequest>
670 for RmIpFromBlocklistSvc<T> {
671 type Response = super::RmIpFromBlocklistResponse;
672 type Future = BoxFuture<
673 tonic::Response<Self::Response>,
674 tonic::Status,
675 >;
676 fn call(
677 &mut self,
678 request: tonic::Request<super::RmIpFromBlocklistRequest>,
679 ) -> Self::Future {
680 let inner = Arc::clone(&self.0);
681 let fut = async move {
682 <T as Agent>::rm_ip_from_blocklist(&inner, request).await
683 };
684 Box::pin(fut)
685 }
686 }
687 let accept_compression_encodings = self.accept_compression_encodings;
688 let send_compression_encodings = self.send_compression_encodings;
689 let max_decoding_message_size = self.max_decoding_message_size;
690 let max_encoding_message_size = self.max_encoding_message_size;
691 let inner = self.inner.clone();
692 let fut = async move {
693 let method = RmIpFromBlocklistSvc(inner);
694 let codec = tonic_prost::ProstCodec::default();
695 let mut grpc = tonic::server::Grpc::new(codec)
696 .apply_compression_config(
697 accept_compression_encodings,
698 send_compression_encodings,
699 )
700 .apply_max_message_size_config(
701 max_decoding_message_size,
702 max_encoding_message_size,
703 );
704 let res = grpc.unary(method, req).await;
705 Ok(res)
706 };
707 Box::pin(fut)
708 }
709 "/agent.Agent/GetLatencyMetrics" => {
710 #[allow(non_camel_case_types)]
711 struct GetLatencyMetricsSvc<T: Agent>(pub Arc<T>);
712 impl<T: Agent> tonic::server::UnaryService<()>
713 for GetLatencyMetricsSvc<T> {
714 type Response = super::LatencyMetricsResponse;
715 type Future = BoxFuture<
716 tonic::Response<Self::Response>,
717 tonic::Status,
718 >;
719 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
720 let inner = Arc::clone(&self.0);
721 let fut = async move {
722 <T as Agent>::get_latency_metrics(&inner, request).await
723 };
724 Box::pin(fut)
725 }
726 }
727 let accept_compression_encodings = self.accept_compression_encodings;
728 let send_compression_encodings = self.send_compression_encodings;
729 let max_decoding_message_size = self.max_decoding_message_size;
730 let max_encoding_message_size = self.max_encoding_message_size;
731 let inner = self.inner.clone();
732 let fut = async move {
733 let method = GetLatencyMetricsSvc(inner);
734 let codec = tonic_prost::ProstCodec::default();
735 let mut grpc = tonic::server::Grpc::new(codec)
736 .apply_compression_config(
737 accept_compression_encodings,
738 send_compression_encodings,
739 )
740 .apply_max_message_size_config(
741 max_decoding_message_size,
742 max_encoding_message_size,
743 );
744 let res = grpc.unary(method, req).await;
745 Ok(res)
746 };
747 Box::pin(fut)
748 }
749 "/agent.Agent/GetDroppedPacketsMetrics" => {
750 #[allow(non_camel_case_types)]
751 struct GetDroppedPacketsMetricsSvc<T: Agent>(pub Arc<T>);
752 impl<T: Agent> tonic::server::UnaryService<()>
753 for GetDroppedPacketsMetricsSvc<T> {
754 type Response = super::DroppedPacketsResponse;
755 type Future = BoxFuture<
756 tonic::Response<Self::Response>,
757 tonic::Status,
758 >;
759 fn call(&mut self, request: tonic::Request<()>) -> Self::Future {
760 let inner = Arc::clone(&self.0);
761 let fut = async move {
762 <T as Agent>::get_dropped_packets_metrics(&inner, request)
763 .await
764 };
765 Box::pin(fut)
766 }
767 }
768 let accept_compression_encodings = self.accept_compression_encodings;
769 let send_compression_encodings = self.send_compression_encodings;
770 let max_decoding_message_size = self.max_decoding_message_size;
771 let max_encoding_message_size = self.max_encoding_message_size;
772 let inner = self.inner.clone();
773 let fut = async move {
774 let method = GetDroppedPacketsMetricsSvc(inner);
775 let codec = tonic_prost::ProstCodec::default();
776 let mut grpc = tonic::server::Grpc::new(codec)
777 .apply_compression_config(
778 accept_compression_encodings,
779 send_compression_encodings,
780 )
781 .apply_max_message_size_config(
782 max_decoding_message_size,
783 max_encoding_message_size,
784 );
785 let res = grpc.unary(method, req).await;
786 Ok(res)
787 };
788 Box::pin(fut)
789 }
790 _ => {
791 Box::pin(async move {
792 let mut response = http::Response::new(
793 tonic::body::Body::default(),
794 );
795 let headers = response.headers_mut();
796 headers
797 .insert(
798 tonic::Status::GRPC_STATUS,
799 (tonic::Code::Unimplemented as i32).into(),
800 );
801 headers
802 .insert(
803 http::header::CONTENT_TYPE,
804 tonic::metadata::GRPC_CONTENT_TYPE,
805 );
806 Ok(response)
807 })
808 }
809 }
810 }
811 }
812 impl<T> Clone for AgentServer<T> {
813 fn clone(&self) -> Self {
814 let inner = self.inner.clone();
815 Self {
816 inner,
817 accept_compression_encodings: self.accept_compression_encodings,
818 send_compression_encodings: self.send_compression_encodings,
819 max_decoding_message_size: self.max_decoding_message_size,
820 max_encoding_message_size: self.max_encoding_message_size,
821 }
822 }
823 }
824 pub const SERVICE_NAME: &str = "agent.Agent";
826 impl<T> tonic::server::NamedService for AgentServer<T> {
827 const NAME: &'static str = SERVICE_NAME;
828 }
829}