xds_api/generated/
envoy.service.metrics.v3.rs

1// This file is @generated by prost-build.
2#[derive(Clone, Copy, PartialEq, ::prost::Message)]
3pub struct StreamMetricsResponse {}
4impl ::prost::Name for StreamMetricsResponse {
5    const NAME: &'static str = "StreamMetricsResponse";
6    const PACKAGE: &'static str = "envoy.service.metrics.v3";
7    fn full_name() -> ::prost::alloc::string::String {
8        "envoy.service.metrics.v3.StreamMetricsResponse".into()
9    }
10    fn type_url() -> ::prost::alloc::string::String {
11        "type.googleapis.com/envoy.service.metrics.v3.StreamMetricsResponse".into()
12    }
13}
14#[derive(Clone, PartialEq, ::prost::Message)]
15pub struct StreamMetricsMessage {
16    /// Identifier data effectively is a structured metadata. As a performance optimization this will
17    /// only be sent in the first message on the stream.
18    #[prost(message, optional, tag = "1")]
19    pub identifier: ::core::option::Option<stream_metrics_message::Identifier>,
20    /// A list of metric entries
21    #[prost(message, repeated, tag = "2")]
22    pub envoy_metrics: ::prost::alloc::vec::Vec<
23        super::super::super::super::io::prometheus::client::MetricFamily,
24    >,
25}
26/// Nested message and enum types in `StreamMetricsMessage`.
27pub mod stream_metrics_message {
28    #[derive(Clone, PartialEq, ::prost::Message)]
29    pub struct Identifier {
30        /// The node sending metrics over the stream.
31        #[prost(message, optional, tag = "1")]
32        pub node: ::core::option::Option<
33            super::super::super::super::config::core::v3::Node,
34        >,
35    }
36    impl ::prost::Name for Identifier {
37        const NAME: &'static str = "Identifier";
38        const PACKAGE: &'static str = "envoy.service.metrics.v3";
39        fn full_name() -> ::prost::alloc::string::String {
40            "envoy.service.metrics.v3.StreamMetricsMessage.Identifier".into()
41        }
42        fn type_url() -> ::prost::alloc::string::String {
43            "type.googleapis.com/envoy.service.metrics.v3.StreamMetricsMessage.Identifier"
44                .into()
45        }
46    }
47}
48impl ::prost::Name for StreamMetricsMessage {
49    const NAME: &'static str = "StreamMetricsMessage";
50    const PACKAGE: &'static str = "envoy.service.metrics.v3";
51    fn full_name() -> ::prost::alloc::string::String {
52        "envoy.service.metrics.v3.StreamMetricsMessage".into()
53    }
54    fn type_url() -> ::prost::alloc::string::String {
55        "type.googleapis.com/envoy.service.metrics.v3.StreamMetricsMessage".into()
56    }
57}
58/// Generated client implementations.
59pub mod metrics_service_client {
60    #![allow(
61        unused_variables,
62        dead_code,
63        missing_docs,
64        clippy::wildcard_imports,
65        clippy::let_unit_value,
66    )]
67    use tonic::codegen::*;
68    use tonic::codegen::http::Uri;
69    /// Service for streaming metrics to server that consumes the metrics data. It uses Prometheus metric
70    /// data model as a standard to represent metrics information.
71    #[derive(Debug, Clone)]
72    pub struct MetricsServiceClient<T> {
73        inner: tonic::client::Grpc<T>,
74    }
75    impl<T> MetricsServiceClient<T>
76    where
77        T: tonic::client::GrpcService<tonic::body::BoxBody>,
78        T::Error: Into<StdError>,
79        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
80        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
81    {
82        pub fn new(inner: T) -> Self {
83            let inner = tonic::client::Grpc::new(inner);
84            Self { inner }
85        }
86        pub fn with_origin(inner: T, origin: Uri) -> Self {
87            let inner = tonic::client::Grpc::with_origin(inner, origin);
88            Self { inner }
89        }
90        pub fn with_interceptor<F>(
91            inner: T,
92            interceptor: F,
93        ) -> MetricsServiceClient<InterceptedService<T, F>>
94        where
95            F: tonic::service::Interceptor,
96            T::ResponseBody: Default,
97            T: tonic::codegen::Service<
98                http::Request<tonic::body::BoxBody>,
99                Response = http::Response<
100                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
101                >,
102            >,
103            <T as tonic::codegen::Service<
104                http::Request<tonic::body::BoxBody>,
105            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
106        {
107            MetricsServiceClient::new(InterceptedService::new(inner, interceptor))
108        }
109        /// Compress requests with the given encoding.
110        ///
111        /// This requires the server to support it otherwise it might respond with an
112        /// error.
113        #[must_use]
114        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
115            self.inner = self.inner.send_compressed(encoding);
116            self
117        }
118        /// Enable decompressing responses.
119        #[must_use]
120        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
121            self.inner = self.inner.accept_compressed(encoding);
122            self
123        }
124        /// Limits the maximum size of a decoded message.
125        ///
126        /// Default: `4MB`
127        #[must_use]
128        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
129            self.inner = self.inner.max_decoding_message_size(limit);
130            self
131        }
132        /// Limits the maximum size of an encoded message.
133        ///
134        /// Default: `usize::MAX`
135        #[must_use]
136        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
137            self.inner = self.inner.max_encoding_message_size(limit);
138            self
139        }
140        /// Envoy will connect and send StreamMetricsMessage messages forever. It does not expect any
141        /// response to be sent as nothing would be done in the case of failure.
142        pub async fn stream_metrics(
143            &mut self,
144            request: impl tonic::IntoStreamingRequest<
145                Message = super::StreamMetricsMessage,
146            >,
147        ) -> std::result::Result<
148            tonic::Response<super::StreamMetricsResponse>,
149            tonic::Status,
150        > {
151            self.inner
152                .ready()
153                .await
154                .map_err(|e| {
155                    tonic::Status::unknown(
156                        format!("Service was not ready: {}", e.into()),
157                    )
158                })?;
159            let codec = tonic::codec::ProstCodec::default();
160            let path = http::uri::PathAndQuery::from_static(
161                "/envoy.service.metrics.v3.MetricsService/StreamMetrics",
162            );
163            let mut req = request.into_streaming_request();
164            req.extensions_mut()
165                .insert(
166                    GrpcMethod::new(
167                        "envoy.service.metrics.v3.MetricsService",
168                        "StreamMetrics",
169                    ),
170                );
171            self.inner.client_streaming(req, path, codec).await
172        }
173    }
174}
175/// Generated server implementations.
176pub mod metrics_service_server {
177    #![allow(
178        unused_variables,
179        dead_code,
180        missing_docs,
181        clippy::wildcard_imports,
182        clippy::let_unit_value,
183    )]
184    use tonic::codegen::*;
185    /// Generated trait containing gRPC methods that should be implemented for use with MetricsServiceServer.
186    #[async_trait]
187    pub trait MetricsService: std::marker::Send + std::marker::Sync + 'static {
188        /// Envoy will connect and send StreamMetricsMessage messages forever. It does not expect any
189        /// response to be sent as nothing would be done in the case of failure.
190        async fn stream_metrics(
191            &self,
192            request: tonic::Request<tonic::Streaming<super::StreamMetricsMessage>>,
193        ) -> std::result::Result<
194            tonic::Response<super::StreamMetricsResponse>,
195            tonic::Status,
196        >;
197    }
198    /// Service for streaming metrics to server that consumes the metrics data. It uses Prometheus metric
199    /// data model as a standard to represent metrics information.
200    #[derive(Debug)]
201    pub struct MetricsServiceServer<T> {
202        inner: Arc<T>,
203        accept_compression_encodings: EnabledCompressionEncodings,
204        send_compression_encodings: EnabledCompressionEncodings,
205        max_decoding_message_size: Option<usize>,
206        max_encoding_message_size: Option<usize>,
207    }
208    impl<T> MetricsServiceServer<T> {
209        pub fn new(inner: T) -> Self {
210            Self::from_arc(Arc::new(inner))
211        }
212        pub fn from_arc(inner: Arc<T>) -> Self {
213            Self {
214                inner,
215                accept_compression_encodings: Default::default(),
216                send_compression_encodings: Default::default(),
217                max_decoding_message_size: None,
218                max_encoding_message_size: None,
219            }
220        }
221        pub fn with_interceptor<F>(
222            inner: T,
223            interceptor: F,
224        ) -> InterceptedService<Self, F>
225        where
226            F: tonic::service::Interceptor,
227        {
228            InterceptedService::new(Self::new(inner), interceptor)
229        }
230        /// Enable decompressing requests with the given encoding.
231        #[must_use]
232        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
233            self.accept_compression_encodings.enable(encoding);
234            self
235        }
236        /// Compress responses with the given encoding, if the client supports it.
237        #[must_use]
238        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
239            self.send_compression_encodings.enable(encoding);
240            self
241        }
242        /// Limits the maximum size of a decoded message.
243        ///
244        /// Default: `4MB`
245        #[must_use]
246        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
247            self.max_decoding_message_size = Some(limit);
248            self
249        }
250        /// Limits the maximum size of an encoded message.
251        ///
252        /// Default: `usize::MAX`
253        #[must_use]
254        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
255            self.max_encoding_message_size = Some(limit);
256            self
257        }
258    }
259    impl<T, B> tonic::codegen::Service<http::Request<B>> for MetricsServiceServer<T>
260    where
261        T: MetricsService,
262        B: Body + std::marker::Send + 'static,
263        B::Error: Into<StdError> + std::marker::Send + 'static,
264    {
265        type Response = http::Response<tonic::body::BoxBody>;
266        type Error = std::convert::Infallible;
267        type Future = BoxFuture<Self::Response, Self::Error>;
268        fn poll_ready(
269            &mut self,
270            _cx: &mut Context<'_>,
271        ) -> Poll<std::result::Result<(), Self::Error>> {
272            Poll::Ready(Ok(()))
273        }
274        fn call(&mut self, req: http::Request<B>) -> Self::Future {
275            match req.uri().path() {
276                "/envoy.service.metrics.v3.MetricsService/StreamMetrics" => {
277                    #[allow(non_camel_case_types)]
278                    struct StreamMetricsSvc<T: MetricsService>(pub Arc<T>);
279                    impl<
280                        T: MetricsService,
281                    > tonic::server::ClientStreamingService<super::StreamMetricsMessage>
282                    for StreamMetricsSvc<T> {
283                        type Response = super::StreamMetricsResponse;
284                        type Future = BoxFuture<
285                            tonic::Response<Self::Response>,
286                            tonic::Status,
287                        >;
288                        fn call(
289                            &mut self,
290                            request: tonic::Request<
291                                tonic::Streaming<super::StreamMetricsMessage>,
292                            >,
293                        ) -> Self::Future {
294                            let inner = Arc::clone(&self.0);
295                            let fut = async move {
296                                <T as MetricsService>::stream_metrics(&inner, request).await
297                            };
298                            Box::pin(fut)
299                        }
300                    }
301                    let accept_compression_encodings = self.accept_compression_encodings;
302                    let send_compression_encodings = self.send_compression_encodings;
303                    let max_decoding_message_size = self.max_decoding_message_size;
304                    let max_encoding_message_size = self.max_encoding_message_size;
305                    let inner = self.inner.clone();
306                    let fut = async move {
307                        let method = StreamMetricsSvc(inner);
308                        let codec = tonic::codec::ProstCodec::default();
309                        let mut grpc = tonic::server::Grpc::new(codec)
310                            .apply_compression_config(
311                                accept_compression_encodings,
312                                send_compression_encodings,
313                            )
314                            .apply_max_message_size_config(
315                                max_decoding_message_size,
316                                max_encoding_message_size,
317                            );
318                        let res = grpc.client_streaming(method, req).await;
319                        Ok(res)
320                    };
321                    Box::pin(fut)
322                }
323                _ => {
324                    Box::pin(async move {
325                        let mut response = http::Response::new(empty_body());
326                        let headers = response.headers_mut();
327                        headers
328                            .insert(
329                                tonic::Status::GRPC_STATUS,
330                                (tonic::Code::Unimplemented as i32).into(),
331                            );
332                        headers
333                            .insert(
334                                http::header::CONTENT_TYPE,
335                                tonic::metadata::GRPC_CONTENT_TYPE,
336                            );
337                        Ok(response)
338                    })
339                }
340            }
341        }
342    }
343    impl<T> Clone for MetricsServiceServer<T> {
344        fn clone(&self) -> Self {
345            let inner = self.inner.clone();
346            Self {
347                inner,
348                accept_compression_encodings: self.accept_compression_encodings,
349                send_compression_encodings: self.send_compression_encodings,
350                max_decoding_message_size: self.max_decoding_message_size,
351                max_encoding_message_size: self.max_encoding_message_size,
352            }
353        }
354    }
355    /// Generated gRPC service name
356    pub const SERVICE_NAME: &str = "envoy.service.metrics.v3.MetricsService";
357    impl<T> tonic::server::NamedService for MetricsServiceServer<T> {
358        const NAME: &'static str = SERVICE_NAME;
359    }
360}