linkerd2_proxy_api/gen/
io.linkerd.proxy.tap.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct ObserveRequest {
4    /// Limits the number of event keys that will be returned by this tap.
5    #[prost(uint32, tag = "1")]
6    pub limit: u32,
7    /// Encodes request-matching logic.
8    #[prost(message, optional, tag = "2")]
9    pub r#match: ::core::option::Option<observe_request::Match>,
10    /// Conditionally extracts components from requests and responses to include
11    /// in tap events
12    #[prost(message, optional, tag = "3")]
13    pub extract: ::core::option::Option<observe_request::Extract>,
14}
15/// Nested message and enum types in `ObserveRequest`.
16pub mod observe_request {
17    #[derive(Clone, PartialEq, ::prost::Message)]
18    pub struct Match {
19        #[prost(oneof = "r#match::Match", tags = "1, 2, 3, 4, 5, 6, 7, 8")]
20        pub r#match: ::core::option::Option<r#match::Match>,
21    }
22    /// Nested message and enum types in `Match`.
23    pub mod r#match {
24        #[derive(Clone, PartialEq, ::prost::Message)]
25        pub struct Seq {
26            #[prost(message, repeated, tag = "1")]
27            pub matches: ::prost::alloc::vec::Vec<super::Match>,
28        }
29        #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
30        pub struct Label {
31            #[prost(string, tag = "1")]
32            pub key: ::prost::alloc::string::String,
33            #[prost(string, tag = "2")]
34            pub value: ::prost::alloc::string::String,
35        }
36        #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
37        pub struct Tcp {
38            #[prost(oneof = "tcp::Match", tags = "1, 3")]
39            pub r#match: ::core::option::Option<tcp::Match>,
40        }
41        /// Nested message and enum types in `Tcp`.
42        pub mod tcp {
43            #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
44            pub struct Netmask {
45                #[prost(message, optional, tag = "1")]
46                pub ip: ::core::option::Option<
47                    super::super::super::super::net::IpAddress,
48                >,
49                #[prost(uint32, tag = "2")]
50                pub mask: u32,
51            }
52            /// If either a minimum or maximum is not specified, the range is
53            /// considered to be over a discrete value.
54            #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
55            pub struct PortRange {
56                /// Minimum matching port value (inclusive), if specified.
57                #[prost(uint32, tag = "1")]
58                pub min: u32,
59                /// Maximum matching port value (inclusive), if specified.
60                #[prost(uint32, tag = "2")]
61                pub max: u32,
62            }
63            #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
64            pub enum Match {
65                #[prost(message, tag = "1")]
66                Netmask(Netmask),
67                #[prost(message, tag = "3")]
68                Ports(PortRange),
69            }
70        }
71        #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
72        pub struct Http {
73            #[prost(oneof = "http::Match", tags = "1, 3, 2, 4")]
74            pub r#match: ::core::option::Option<http::Match>,
75        }
76        /// Nested message and enum types in `Http`.
77        pub mod http {
78            #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
79            pub struct StringMatch {
80                #[prost(oneof = "string_match::Match", tags = "1, 2")]
81                pub r#match: ::core::option::Option<string_match::Match>,
82            }
83            /// Nested message and enum types in `StringMatch`.
84            pub mod string_match {
85                #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
86                pub enum Match {
87                    #[prost(string, tag = "1")]
88                    Exact(::prost::alloc::string::String),
89                    #[prost(string, tag = "2")]
90                    Prefix(::prost::alloc::string::String),
91                }
92            }
93            #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
94            pub enum Match {
95                #[prost(message, tag = "1")]
96                Scheme(super::super::super::super::http_types::Scheme),
97                #[prost(message, tag = "3")]
98                Method(super::super::super::super::http_types::HttpMethod),
99                #[prost(message, tag = "2")]
100                Authority(StringMatch),
101                /// TODO Header        header    = 4;
102                #[prost(message, tag = "4")]
103                Path(StringMatch),
104            }
105        }
106        #[derive(Clone, PartialEq, ::prost::Oneof)]
107        pub enum Match {
108            #[prost(message, tag = "1")]
109            All(Seq),
110            #[prost(message, tag = "2")]
111            Any(Seq),
112            #[prost(message, tag = "3")]
113            Not(::prost::alloc::boxed::Box<super::Match>),
114            #[prost(message, tag = "4")]
115            Source(Tcp),
116            #[prost(message, tag = "5")]
117            Destination(Tcp),
118            #[prost(message, tag = "6")]
119            Http(Http),
120            #[prost(message, tag = "7")]
121            DestinationLabel(Label),
122            #[prost(message, tag = "8")]
123            RouteLabel(Label),
124        }
125    }
126    #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
127    pub struct Extract {
128        #[prost(oneof = "extract::Extract", tags = "1")]
129        pub extract: ::core::option::Option<extract::Extract>,
130    }
131    /// Nested message and enum types in `Extract`.
132    pub mod extract {
133        #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
134        pub struct Http {
135            #[prost(oneof = "http::Extract", tags = "1")]
136            pub extract: ::core::option::Option<http::Extract>,
137        }
138        /// Nested message and enum types in `Http`.
139        pub mod http {
140            #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
141            pub struct Headers {}
142            #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
143            pub enum Extract {
144                #[prost(message, tag = "1")]
145                Headers(Headers),
146            }
147        }
148        #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
149        pub enum Extract {
150            #[prost(message, tag = "1")]
151            Http(Http),
152        }
153    }
154}
155#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
156pub struct Eos {
157    #[prost(oneof = "eos::End", tags = "1, 2")]
158    pub end: ::core::option::Option<eos::End>,
159}
160/// Nested message and enum types in `Eos`.
161pub mod eos {
162    #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Oneof)]
163    pub enum End {
164        #[prost(uint32, tag = "1")]
165        GrpcStatusCode(u32),
166        #[prost(uint32, tag = "2")]
167        ResetErrorCode(u32),
168    }
169}
170#[derive(Clone, PartialEq, ::prost::Message)]
171pub struct TapEvent {
172    #[prost(message, optional, tag = "1")]
173    pub source: ::core::option::Option<super::net::TcpAddress>,
174    #[prost(message, optional, tag = "5")]
175    pub source_meta: ::core::option::Option<tap_event::EndpointMeta>,
176    #[prost(message, optional, tag = "7")]
177    pub route_meta: ::core::option::Option<tap_event::RouteMeta>,
178    #[prost(message, optional, tag = "2")]
179    pub destination: ::core::option::Option<super::net::TcpAddress>,
180    #[prost(message, optional, tag = "4")]
181    pub destination_meta: ::core::option::Option<tap_event::EndpointMeta>,
182    #[prost(enumeration = "tap_event::ProxyDirection", tag = "6")]
183    pub proxy_direction: i32,
184    #[prost(oneof = "tap_event::Event", tags = "3")]
185    pub event: ::core::option::Option<tap_event::Event>,
186}
187/// Nested message and enum types in `TapEvent`.
188pub mod tap_event {
189    #[derive(Clone, PartialEq, ::prost::Message)]
190    pub struct EndpointMeta {
191        #[prost(map = "string, string", tag = "1")]
192        pub labels: ::std::collections::HashMap<
193            ::prost::alloc::string::String,
194            ::prost::alloc::string::String,
195        >,
196    }
197    #[derive(Clone, PartialEq, ::prost::Message)]
198    pub struct RouteMeta {
199        #[prost(map = "string, string", tag = "1")]
200        pub labels: ::std::collections::HashMap<
201            ::prost::alloc::string::String,
202            ::prost::alloc::string::String,
203        >,
204    }
205    #[derive(Clone, PartialEq, ::prost::Message)]
206    pub struct Http {
207        #[prost(oneof = "http::Event", tags = "1, 2, 3")]
208        pub event: ::core::option::Option<http::Event>,
209    }
210    /// Nested message and enum types in `Http`.
211    pub mod http {
212        #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
213        pub struct StreamId {
214            /// A randomized base (stable across a process's runtime)
215            #[prost(uint32, tag = "1")]
216            pub base: u32,
217            /// A stream id unique within the lifetime of `base`.
218            #[prost(uint64, tag = "2")]
219            pub stream: u64,
220        }
221        #[derive(Clone, PartialEq, ::prost::Message)]
222        pub struct RequestInit {
223            #[prost(message, optional, tag = "1")]
224            pub id: ::core::option::Option<StreamId>,
225            #[prost(message, optional, tag = "2")]
226            pub method: ::core::option::Option<
227                super::super::super::http_types::HttpMethod,
228            >,
229            #[prost(message, optional, tag = "3")]
230            pub scheme: ::core::option::Option<super::super::super::http_types::Scheme>,
231            #[prost(string, tag = "4")]
232            pub authority: ::prost::alloc::string::String,
233            #[prost(string, tag = "5")]
234            pub path: ::prost::alloc::string::String,
235            #[prost(message, optional, tag = "6")]
236            pub headers: ::core::option::Option<
237                super::super::super::http_types::Headers,
238            >,
239        }
240        #[derive(Clone, PartialEq, ::prost::Message)]
241        pub struct ResponseInit {
242            #[prost(message, optional, tag = "1")]
243            pub id: ::core::option::Option<StreamId>,
244            #[prost(message, optional, tag = "2")]
245            pub since_request_init: ::core::option::Option<::prost_types::Duration>,
246            #[prost(uint32, tag = "3")]
247            pub http_status: u32,
248            #[prost(message, optional, tag = "4")]
249            pub headers: ::core::option::Option<
250                super::super::super::http_types::Headers,
251            >,
252        }
253        #[derive(Clone, PartialEq, ::prost::Message)]
254        pub struct ResponseEnd {
255            #[prost(message, optional, tag = "1")]
256            pub id: ::core::option::Option<StreamId>,
257            #[prost(message, optional, tag = "2")]
258            pub since_request_init: ::core::option::Option<::prost_types::Duration>,
259            #[prost(message, optional, tag = "3")]
260            pub since_response_init: ::core::option::Option<::prost_types::Duration>,
261            #[prost(uint64, tag = "4")]
262            pub response_bytes: u64,
263            #[prost(message, optional, tag = "5")]
264            pub eos: ::core::option::Option<super::super::Eos>,
265            #[prost(message, optional, tag = "6")]
266            pub trailers: ::core::option::Option<
267                super::super::super::http_types::Headers,
268            >,
269        }
270        #[derive(Clone, PartialEq, ::prost::Oneof)]
271        pub enum Event {
272            #[prost(message, tag = "1")]
273            RequestInit(RequestInit),
274            #[prost(message, tag = "2")]
275            ResponseInit(ResponseInit),
276            #[prost(message, tag = "3")]
277            ResponseEnd(ResponseEnd),
278        }
279    }
280    #[derive(
281        Clone,
282        Copy,
283        Debug,
284        PartialEq,
285        Eq,
286        Hash,
287        PartialOrd,
288        Ord,
289        ::prost::Enumeration
290    )]
291    #[repr(i32)]
292    pub enum ProxyDirection {
293        Unknown = 0,
294        Inbound = 1,
295        Outbound = 2,
296    }
297    impl ProxyDirection {
298        /// String value of the enum field names used in the ProtoBuf definition.
299        ///
300        /// The values are not transformed in any way and thus are considered stable
301        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
302        pub fn as_str_name(&self) -> &'static str {
303            match self {
304                Self::Unknown => "UNKNOWN",
305                Self::Inbound => "INBOUND",
306                Self::Outbound => "OUTBOUND",
307            }
308        }
309        /// Creates an enum from field names used in the ProtoBuf definition.
310        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
311            match value {
312                "UNKNOWN" => Some(Self::Unknown),
313                "INBOUND" => Some(Self::Inbound),
314                "OUTBOUND" => Some(Self::Outbound),
315                _ => None,
316            }
317        }
318    }
319    #[derive(Clone, PartialEq, ::prost::Oneof)]
320    pub enum Event {
321        #[prost(message, tag = "3")]
322        Http(Http),
323    }
324}
325/// Generated client implementations.
326pub mod tap_client {
327    #![allow(
328        unused_variables,
329        dead_code,
330        missing_docs,
331        clippy::wildcard_imports,
332        clippy::let_unit_value,
333    )]
334    use tonic::codegen::*;
335    use tonic::codegen::http::Uri;
336    /// A service exposed by proxy instances to setup
337    #[derive(Debug, Clone)]
338    pub struct TapClient<T> {
339        inner: tonic::client::Grpc<T>,
340    }
341    impl TapClient<tonic::transport::Channel> {
342        /// Attempt to create a new client by connecting to a given endpoint.
343        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
344        where
345            D: TryInto<tonic::transport::Endpoint>,
346            D::Error: Into<StdError>,
347        {
348            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
349            Ok(Self::new(conn))
350        }
351    }
352    impl<T> TapClient<T>
353    where
354        T: tonic::client::GrpcService<tonic::body::Body>,
355        T::Error: Into<StdError>,
356        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
357        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
358    {
359        pub fn new(inner: T) -> Self {
360            let inner = tonic::client::Grpc::new(inner);
361            Self { inner }
362        }
363        pub fn with_origin(inner: T, origin: Uri) -> Self {
364            let inner = tonic::client::Grpc::with_origin(inner, origin);
365            Self { inner }
366        }
367        pub fn with_interceptor<F>(
368            inner: T,
369            interceptor: F,
370        ) -> TapClient<InterceptedService<T, F>>
371        where
372            F: tonic::service::Interceptor,
373            T::ResponseBody: Default,
374            T: tonic::codegen::Service<
375                http::Request<tonic::body::Body>,
376                Response = http::Response<
377                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
378                >,
379            >,
380            <T as tonic::codegen::Service<
381                http::Request<tonic::body::Body>,
382            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
383        {
384            TapClient::new(InterceptedService::new(inner, interceptor))
385        }
386        /// Compress requests with the given encoding.
387        ///
388        /// This requires the server to support it otherwise it might respond with an
389        /// error.
390        #[must_use]
391        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
392            self.inner = self.inner.send_compressed(encoding);
393            self
394        }
395        /// Enable decompressing responses.
396        #[must_use]
397        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
398            self.inner = self.inner.accept_compressed(encoding);
399            self
400        }
401        /// Limits the maximum size of a decoded message.
402        ///
403        /// Default: `4MB`
404        #[must_use]
405        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
406            self.inner = self.inner.max_decoding_message_size(limit);
407            self
408        }
409        /// Limits the maximum size of an encoded message.
410        ///
411        /// Default: `usize::MAX`
412        #[must_use]
413        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
414            self.inner = self.inner.max_encoding_message_size(limit);
415            self
416        }
417        pub async fn observe(
418            &mut self,
419            request: impl tonic::IntoRequest<super::ObserveRequest>,
420        ) -> std::result::Result<
421            tonic::Response<tonic::codec::Streaming<super::TapEvent>>,
422            tonic::Status,
423        > {
424            self.inner
425                .ready()
426                .await
427                .map_err(|e| {
428                    tonic::Status::unknown(
429                        format!("Service was not ready: {}", e.into()),
430                    )
431                })?;
432            let codec = tonic_prost::ProstCodec::default();
433            let path = http::uri::PathAndQuery::from_static(
434                "/io.linkerd.proxy.tap.Tap/Observe",
435            );
436            let mut req = request.into_request();
437            req.extensions_mut()
438                .insert(GrpcMethod::new("io.linkerd.proxy.tap.Tap", "Observe"));
439            self.inner.server_streaming(req, path, codec).await
440        }
441    }
442}
443/// Generated server implementations.
444pub mod tap_server {
445    #![allow(
446        unused_variables,
447        dead_code,
448        missing_docs,
449        clippy::wildcard_imports,
450        clippy::let_unit_value,
451    )]
452    use tonic::codegen::*;
453    /// Generated trait containing gRPC methods that should be implemented for use with TapServer.
454    #[async_trait]
455    pub trait Tap: std::marker::Send + std::marker::Sync + 'static {
456        /// Server streaming response type for the Observe method.
457        type ObserveStream: tonic::codegen::tokio_stream::Stream<
458                Item = std::result::Result<super::TapEvent, tonic::Status>,
459            >
460            + std::marker::Send
461            + 'static;
462        async fn observe(
463            &self,
464            request: tonic::Request<super::ObserveRequest>,
465        ) -> std::result::Result<tonic::Response<Self::ObserveStream>, tonic::Status>;
466    }
467    /// A service exposed by proxy instances to setup
468    #[derive(Debug)]
469    pub struct TapServer<T> {
470        inner: Arc<T>,
471        accept_compression_encodings: EnabledCompressionEncodings,
472        send_compression_encodings: EnabledCompressionEncodings,
473        max_decoding_message_size: Option<usize>,
474        max_encoding_message_size: Option<usize>,
475    }
476    impl<T> TapServer<T> {
477        pub fn new(inner: T) -> Self {
478            Self::from_arc(Arc::new(inner))
479        }
480        pub fn from_arc(inner: Arc<T>) -> Self {
481            Self {
482                inner,
483                accept_compression_encodings: Default::default(),
484                send_compression_encodings: Default::default(),
485                max_decoding_message_size: None,
486                max_encoding_message_size: None,
487            }
488        }
489        pub fn with_interceptor<F>(
490            inner: T,
491            interceptor: F,
492        ) -> InterceptedService<Self, F>
493        where
494            F: tonic::service::Interceptor,
495        {
496            InterceptedService::new(Self::new(inner), interceptor)
497        }
498        /// Enable decompressing requests with the given encoding.
499        #[must_use]
500        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
501            self.accept_compression_encodings.enable(encoding);
502            self
503        }
504        /// Compress responses with the given encoding, if the client supports it.
505        #[must_use]
506        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
507            self.send_compression_encodings.enable(encoding);
508            self
509        }
510        /// Limits the maximum size of a decoded message.
511        ///
512        /// Default: `4MB`
513        #[must_use]
514        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
515            self.max_decoding_message_size = Some(limit);
516            self
517        }
518        /// Limits the maximum size of an encoded message.
519        ///
520        /// Default: `usize::MAX`
521        #[must_use]
522        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
523            self.max_encoding_message_size = Some(limit);
524            self
525        }
526    }
527    impl<T, B> tonic::codegen::Service<http::Request<B>> for TapServer<T>
528    where
529        T: Tap,
530        B: Body + std::marker::Send + 'static,
531        B::Error: Into<StdError> + std::marker::Send + 'static,
532    {
533        type Response = http::Response<tonic::body::Body>;
534        type Error = std::convert::Infallible;
535        type Future = BoxFuture<Self::Response, Self::Error>;
536        fn poll_ready(
537            &mut self,
538            _cx: &mut Context<'_>,
539        ) -> Poll<std::result::Result<(), Self::Error>> {
540            Poll::Ready(Ok(()))
541        }
542        fn call(&mut self, req: http::Request<B>) -> Self::Future {
543            match req.uri().path() {
544                "/io.linkerd.proxy.tap.Tap/Observe" => {
545                    #[allow(non_camel_case_types)]
546                    struct ObserveSvc<T: Tap>(pub Arc<T>);
547                    impl<
548                        T: Tap,
549                    > tonic::server::ServerStreamingService<super::ObserveRequest>
550                    for ObserveSvc<T> {
551                        type Response = super::TapEvent;
552                        type ResponseStream = T::ObserveStream;
553                        type Future = BoxFuture<
554                            tonic::Response<Self::ResponseStream>,
555                            tonic::Status,
556                        >;
557                        fn call(
558                            &mut self,
559                            request: tonic::Request<super::ObserveRequest>,
560                        ) -> Self::Future {
561                            let inner = Arc::clone(&self.0);
562                            let fut = async move {
563                                <T as Tap>::observe(&inner, request).await
564                            };
565                            Box::pin(fut)
566                        }
567                    }
568                    let accept_compression_encodings = self.accept_compression_encodings;
569                    let send_compression_encodings = self.send_compression_encodings;
570                    let max_decoding_message_size = self.max_decoding_message_size;
571                    let max_encoding_message_size = self.max_encoding_message_size;
572                    let inner = self.inner.clone();
573                    let fut = async move {
574                        let method = ObserveSvc(inner);
575                        let codec = tonic_prost::ProstCodec::default();
576                        let mut grpc = tonic::server::Grpc::new(codec)
577                            .apply_compression_config(
578                                accept_compression_encodings,
579                                send_compression_encodings,
580                            )
581                            .apply_max_message_size_config(
582                                max_decoding_message_size,
583                                max_encoding_message_size,
584                            );
585                        let res = grpc.server_streaming(method, req).await;
586                        Ok(res)
587                    };
588                    Box::pin(fut)
589                }
590                _ => {
591                    Box::pin(async move {
592                        let mut response = http::Response::new(
593                            tonic::body::Body::default(),
594                        );
595                        let headers = response.headers_mut();
596                        headers
597                            .insert(
598                                tonic::Status::GRPC_STATUS,
599                                (tonic::Code::Unimplemented as i32).into(),
600                            );
601                        headers
602                            .insert(
603                                http::header::CONTENT_TYPE,
604                                tonic::metadata::GRPC_CONTENT_TYPE,
605                            );
606                        Ok(response)
607                    })
608                }
609            }
610        }
611    }
612    impl<T> Clone for TapServer<T> {
613        fn clone(&self) -> Self {
614            let inner = self.inner.clone();
615            Self {
616                inner,
617                accept_compression_encodings: self.accept_compression_encodings,
618                send_compression_encodings: self.send_compression_encodings,
619                max_decoding_message_size: self.max_decoding_message_size,
620                max_encoding_message_size: self.max_encoding_message_size,
621            }
622        }
623    }
624    /// Generated gRPC service name
625    pub const SERVICE_NAME: &str = "io.linkerd.proxy.tap.Tap";
626    impl<T> tonic::server::NamedService for TapServer<T> {
627        const NAME: &'static str = SERVICE_NAME;
628    }
629}