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

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