Skip to main content

pole_specification/
pole.sidecar.v1.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct ClientHello {
4    #[prost(string, tag = "1")]
5    pub sdk_language: ::prost::alloc::string::String,
6    #[prost(string, tag = "2")]
7    pub sdk_version: ::prost::alloc::string::String,
8    #[prost(enumeration = "Protocol", repeated, tag = "3")]
9    pub supported_protocols: ::prost::alloc::vec::Vec<i32>,
10}
11#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
12pub struct ClientEvent {
13    #[prost(oneof = "client_event::Event", tags = "1, 2, 3")]
14    pub event: ::core::option::Option<client_event::Event>,
15}
16/// Nested message and enum types in `ClientEvent`.
17pub mod client_event {
18    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
19    pub enum Event {
20        #[prost(message, tag = "1")]
21        Hello(super::ClientHello),
22        #[prost(message, tag = "2")]
23        RegisterLocalService(super::LocalServiceRegistration),
24        #[prost(message, tag = "3")]
25        UnregisterLocalService(super::LocalServiceUnregistration),
26    }
27}
28#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
29pub struct Listener {
30    #[prost(enumeration = "Protocol", tag = "1")]
31    pub protocol: i32,
32    #[prost(uint32, tag = "2")]
33    pub port: u32,
34}
35#[derive(Clone, PartialEq, ::prost::Message)]
36pub struct ListenerSnapshot {
37    /// These listeners are loopback-only outbound listeners used by the local
38    /// Thin SDK. Ingress listeners are never exposed through bootstrap.
39    #[prost(message, repeated, tag = "1")]
40    pub listeners: ::prost::alloc::vec::Vec<Listener>,
41}
42#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
43pub struct LocalServiceRegistration {
44    /// Stable and unique within one OpenControlSession stream.
45    #[prost(string, tag = "1")]
46    pub registration_id: ::prost::alloc::string::String,
47    #[prost(string, tag = "2")]
48    pub namespace: ::prost::alloc::string::String,
49    #[prost(string, tag = "3")]
50    pub service: ::prost::alloc::string::String,
51    #[prost(enumeration = "Protocol", tag = "4")]
52    pub protocol: i32,
53    /// The Sidecar always connects to this port through 127.0.0.1.
54    #[prost(uint32, tag = "5")]
55    pub local_port: u32,
56}
57#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
58pub struct LocalServiceUnregistration {
59    #[prost(string, tag = "1")]
60    pub registration_id: ::prost::alloc::string::String,
61}
62#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
63pub struct LocalServiceStatus {
64    #[prost(string, tag = "1")]
65    pub registration_id: ::prost::alloc::string::String,
66    #[prost(enumeration = "LocalServiceState", tag = "2")]
67    pub state: i32,
68    #[prost(string, tag = "3")]
69    pub message: ::prost::alloc::string::String,
70}
71#[derive(Clone, PartialEq, ::prost::Message)]
72pub struct SidecarEvent {
73    #[prost(oneof = "sidecar_event::Event", tags = "1, 2")]
74    pub event: ::core::option::Option<sidecar_event::Event>,
75}
76/// Nested message and enum types in `SidecarEvent`.
77pub mod sidecar_event {
78    #[derive(Clone, PartialEq, ::prost::Oneof)]
79    pub enum Event {
80        #[prost(message, tag = "1")]
81        ListenerSnapshot(super::ListenerSnapshot),
82        #[prost(message, tag = "2")]
83        LocalServiceStatus(super::LocalServiceStatus),
84    }
85}
86#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
87#[repr(i32)]
88pub enum Protocol {
89    Unspecified = 0,
90    Http = 1,
91    Grpc = 2,
92    Dubbo = 3,
93    Thrift = 4,
94}
95impl Protocol {
96    /// String value of the enum field names used in the ProtoBuf definition.
97    ///
98    /// The values are not transformed in any way and thus are considered stable
99    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
100    pub fn as_str_name(&self) -> &'static str {
101        match self {
102            Self::Unspecified => "PROTOCOL_UNSPECIFIED",
103            Self::Http => "PROTOCOL_HTTP",
104            Self::Grpc => "PROTOCOL_GRPC",
105            Self::Dubbo => "PROTOCOL_DUBBO",
106            Self::Thrift => "PROTOCOL_THRIFT",
107        }
108    }
109    /// Creates an enum from field names used in the ProtoBuf definition.
110    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
111        match value {
112            "PROTOCOL_UNSPECIFIED" => Some(Self::Unspecified),
113            "PROTOCOL_HTTP" => Some(Self::Http),
114            "PROTOCOL_GRPC" => Some(Self::Grpc),
115            "PROTOCOL_DUBBO" => Some(Self::Dubbo),
116            "PROTOCOL_THRIFT" => Some(Self::Thrift),
117            _ => None,
118        }
119    }
120}
121#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
122#[repr(i32)]
123pub enum LocalServiceState {
124    Unspecified = 0,
125    Registered = 1,
126    Unregistered = 2,
127    Rejected = 3,
128}
129impl LocalServiceState {
130    /// String value of the enum field names used in the ProtoBuf definition.
131    ///
132    /// The values are not transformed in any way and thus are considered stable
133    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
134    pub fn as_str_name(&self) -> &'static str {
135        match self {
136            Self::Unspecified => "LOCAL_SERVICE_STATE_UNSPECIFIED",
137            Self::Registered => "LOCAL_SERVICE_STATE_REGISTERED",
138            Self::Unregistered => "LOCAL_SERVICE_STATE_UNREGISTERED",
139            Self::Rejected => "LOCAL_SERVICE_STATE_REJECTED",
140        }
141    }
142    /// Creates an enum from field names used in the ProtoBuf definition.
143    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
144        match value {
145            "LOCAL_SERVICE_STATE_UNSPECIFIED" => Some(Self::Unspecified),
146            "LOCAL_SERVICE_STATE_REGISTERED" => Some(Self::Registered),
147            "LOCAL_SERVICE_STATE_UNREGISTERED" => Some(Self::Unregistered),
148            "LOCAL_SERVICE_STATE_REJECTED" => Some(Self::Rejected),
149            _ => None,
150        }
151    }
152}
153/// Generated client implementations.
154pub mod sidecar_session_service_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)]
165    pub struct SidecarSessionServiceClient<T> {
166        inner: tonic::client::Grpc<T>,
167    }
168    impl SidecarSessionServiceClient<tonic::transport::Channel> {
169        /// Attempt to create a new client by connecting to a given endpoint.
170        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
171        where
172            D: TryInto<tonic::transport::Endpoint>,
173            D::Error: Into<StdError>,
174        {
175            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
176            Ok(Self::new(conn))
177        }
178    }
179    impl<T> SidecarSessionServiceClient<T>
180    where
181        T: tonic::client::GrpcService<tonic::body::Body>,
182        T::Error: Into<StdError>,
183        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
184        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
185    {
186        pub fn new(inner: T) -> Self {
187            let inner = tonic::client::Grpc::new(inner);
188            Self { inner }
189        }
190        pub fn with_origin(inner: T, origin: Uri) -> Self {
191            let inner = tonic::client::Grpc::with_origin(inner, origin);
192            Self { inner }
193        }
194        pub fn with_interceptor<F>(
195            inner: T,
196            interceptor: F,
197        ) -> SidecarSessionServiceClient<InterceptedService<T, F>>
198        where
199            F: tonic::service::Interceptor,
200            T::ResponseBody: Default,
201            T: tonic::codegen::Service<
202                http::Request<tonic::body::Body>,
203                Response = http::Response<
204                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
205                >,
206            >,
207            <T as tonic::codegen::Service<
208                http::Request<tonic::body::Body>,
209            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
210        {
211            SidecarSessionServiceClient::new(InterceptedService::new(inner, interceptor))
212        }
213        /// Compress requests with the given encoding.
214        ///
215        /// This requires the server to support it otherwise it might respond with an
216        /// error.
217        #[must_use]
218        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
219            self.inner = self.inner.send_compressed(encoding);
220            self
221        }
222        /// Enable decompressing responses.
223        #[must_use]
224        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
225            self.inner = self.inner.accept_compressed(encoding);
226            self
227        }
228        /// Limits the maximum size of a decoded message.
229        ///
230        /// Default: `4MB`
231        #[must_use]
232        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
233            self.inner = self.inner.max_decoding_message_size(limit);
234            self
235        }
236        /// Limits the maximum size of an encoded message.
237        ///
238        /// Default: `usize::MAX`
239        #[must_use]
240        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
241            self.inner = self.inner.max_encoding_message_size(limit);
242            self
243        }
244        /// Legacy listener bootstrap retained for existing Thin SDKs.
245        pub async fn open_session(
246            &mut self,
247            request: impl tonic::IntoRequest<super::ClientHello>,
248        ) -> std::result::Result<
249            tonic::Response<tonic::codec::Streaming<super::SidecarEvent>>,
250            tonic::Status,
251        > {
252            self.inner
253                .ready()
254                .await
255                .map_err(|e| {
256                    tonic::Status::unknown(
257                        format!("Service was not ready: {}", e.into()),
258                    )
259                })?;
260            let codec = tonic_prost::ProstCodec::default();
261            let path = http::uri::PathAndQuery::from_static(
262                "/pole.sidecar.v1.SidecarSessionService/OpenSession",
263            );
264            let mut req = request.into_request();
265            req.extensions_mut()
266                .insert(
267                    GrpcMethod::new(
268                        "pole.sidecar.v1.SidecarSessionService",
269                        "OpenSession",
270                    ),
271                );
272            self.inner.server_streaming(req, path, codec).await
273        }
274        /// Long-lived Thin SDK control session. The first ClientEvent must contain
275        /// ClientHello. Registrations belong to this stream and are removed when it
276        /// closes.
277        pub async fn open_control_session(
278            &mut self,
279            request: impl tonic::IntoStreamingRequest<Message = super::ClientEvent>,
280        ) -> std::result::Result<
281            tonic::Response<tonic::codec::Streaming<super::SidecarEvent>>,
282            tonic::Status,
283        > {
284            self.inner
285                .ready()
286                .await
287                .map_err(|e| {
288                    tonic::Status::unknown(
289                        format!("Service was not ready: {}", e.into()),
290                    )
291                })?;
292            let codec = tonic_prost::ProstCodec::default();
293            let path = http::uri::PathAndQuery::from_static(
294                "/pole.sidecar.v1.SidecarSessionService/OpenControlSession",
295            );
296            let mut req = request.into_streaming_request();
297            req.extensions_mut()
298                .insert(
299                    GrpcMethod::new(
300                        "pole.sidecar.v1.SidecarSessionService",
301                        "OpenControlSession",
302                    ),
303                );
304            self.inner.streaming(req, path, codec).await
305        }
306    }
307}
308/// Generated server implementations.
309pub mod sidecar_session_service_server {
310    #![allow(
311        unused_variables,
312        dead_code,
313        missing_docs,
314        clippy::wildcard_imports,
315        clippy::let_unit_value,
316    )]
317    use tonic::codegen::*;
318    /// Generated trait containing gRPC methods that should be implemented for use with SidecarSessionServiceServer.
319    #[async_trait]
320    pub trait SidecarSessionService: std::marker::Send + std::marker::Sync + 'static {
321        /// Server streaming response type for the OpenSession method.
322        type OpenSessionStream: tonic::codegen::tokio_stream::Stream<
323                Item = std::result::Result<super::SidecarEvent, tonic::Status>,
324            >
325            + std::marker::Send
326            + 'static;
327        /// Legacy listener bootstrap retained for existing Thin SDKs.
328        async fn open_session(
329            &self,
330            request: tonic::Request<super::ClientHello>,
331        ) -> std::result::Result<
332            tonic::Response<Self::OpenSessionStream>,
333            tonic::Status,
334        >;
335        /// Server streaming response type for the OpenControlSession method.
336        type OpenControlSessionStream: tonic::codegen::tokio_stream::Stream<
337                Item = std::result::Result<super::SidecarEvent, tonic::Status>,
338            >
339            + std::marker::Send
340            + 'static;
341        /// Long-lived Thin SDK control session. The first ClientEvent must contain
342        /// ClientHello. Registrations belong to this stream and are removed when it
343        /// closes.
344        async fn open_control_session(
345            &self,
346            request: tonic::Request<tonic::Streaming<super::ClientEvent>>,
347        ) -> std::result::Result<
348            tonic::Response<Self::OpenControlSessionStream>,
349            tonic::Status,
350        >;
351    }
352    #[derive(Debug)]
353    pub struct SidecarSessionServiceServer<T> {
354        inner: Arc<T>,
355        accept_compression_encodings: EnabledCompressionEncodings,
356        send_compression_encodings: EnabledCompressionEncodings,
357        max_decoding_message_size: Option<usize>,
358        max_encoding_message_size: Option<usize>,
359    }
360    impl<T> SidecarSessionServiceServer<T> {
361        pub fn new(inner: T) -> Self {
362            Self::from_arc(Arc::new(inner))
363        }
364        pub fn from_arc(inner: Arc<T>) -> Self {
365            Self {
366                inner,
367                accept_compression_encodings: Default::default(),
368                send_compression_encodings: Default::default(),
369                max_decoding_message_size: None,
370                max_encoding_message_size: None,
371            }
372        }
373        pub fn with_interceptor<F>(
374            inner: T,
375            interceptor: F,
376        ) -> InterceptedService<Self, F>
377        where
378            F: tonic::service::Interceptor,
379        {
380            InterceptedService::new(Self::new(inner), interceptor)
381        }
382        /// Enable decompressing requests with the given encoding.
383        #[must_use]
384        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
385            self.accept_compression_encodings.enable(encoding);
386            self
387        }
388        /// Compress responses with the given encoding, if the client supports it.
389        #[must_use]
390        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
391            self.send_compression_encodings.enable(encoding);
392            self
393        }
394        /// Limits the maximum size of a decoded message.
395        ///
396        /// Default: `4MB`
397        #[must_use]
398        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
399            self.max_decoding_message_size = Some(limit);
400            self
401        }
402        /// Limits the maximum size of an encoded message.
403        ///
404        /// Default: `usize::MAX`
405        #[must_use]
406        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
407            self.max_encoding_message_size = Some(limit);
408            self
409        }
410    }
411    impl<T, B> tonic::codegen::Service<http::Request<B>>
412    for SidecarSessionServiceServer<T>
413    where
414        T: SidecarSessionService,
415        B: Body + std::marker::Send + 'static,
416        B::Error: Into<StdError> + std::marker::Send + 'static,
417    {
418        type Response = http::Response<tonic::body::Body>;
419        type Error = std::convert::Infallible;
420        type Future = BoxFuture<Self::Response, Self::Error>;
421        fn poll_ready(
422            &mut self,
423            _cx: &mut Context<'_>,
424        ) -> Poll<std::result::Result<(), Self::Error>> {
425            Poll::Ready(Ok(()))
426        }
427        fn call(&mut self, req: http::Request<B>) -> Self::Future {
428            match req.uri().path() {
429                "/pole.sidecar.v1.SidecarSessionService/OpenSession" => {
430                    #[allow(non_camel_case_types)]
431                    struct OpenSessionSvc<T: SidecarSessionService>(pub Arc<T>);
432                    impl<
433                        T: SidecarSessionService,
434                    > tonic::server::ServerStreamingService<super::ClientHello>
435                    for OpenSessionSvc<T> {
436                        type Response = super::SidecarEvent;
437                        type ResponseStream = T::OpenSessionStream;
438                        type Future = BoxFuture<
439                            tonic::Response<Self::ResponseStream>,
440                            tonic::Status,
441                        >;
442                        fn call(
443                            &mut self,
444                            request: tonic::Request<super::ClientHello>,
445                        ) -> Self::Future {
446                            let inner = Arc::clone(&self.0);
447                            let fut = async move {
448                                <T as SidecarSessionService>::open_session(&inner, request)
449                                    .await
450                            };
451                            Box::pin(fut)
452                        }
453                    }
454                    let accept_compression_encodings = self.accept_compression_encodings;
455                    let send_compression_encodings = self.send_compression_encodings;
456                    let max_decoding_message_size = self.max_decoding_message_size;
457                    let max_encoding_message_size = self.max_encoding_message_size;
458                    let inner = self.inner.clone();
459                    let fut = async move {
460                        let method = OpenSessionSvc(inner);
461                        let codec = tonic_prost::ProstCodec::default();
462                        let mut grpc = tonic::server::Grpc::new(codec)
463                            .apply_compression_config(
464                                accept_compression_encodings,
465                                send_compression_encodings,
466                            )
467                            .apply_max_message_size_config(
468                                max_decoding_message_size,
469                                max_encoding_message_size,
470                            );
471                        let res = grpc.server_streaming(method, req).await;
472                        Ok(res)
473                    };
474                    Box::pin(fut)
475                }
476                "/pole.sidecar.v1.SidecarSessionService/OpenControlSession" => {
477                    #[allow(non_camel_case_types)]
478                    struct OpenControlSessionSvc<T: SidecarSessionService>(pub Arc<T>);
479                    impl<
480                        T: SidecarSessionService,
481                    > tonic::server::StreamingService<super::ClientEvent>
482                    for OpenControlSessionSvc<T> {
483                        type Response = super::SidecarEvent;
484                        type ResponseStream = T::OpenControlSessionStream;
485                        type Future = BoxFuture<
486                            tonic::Response<Self::ResponseStream>,
487                            tonic::Status,
488                        >;
489                        fn call(
490                            &mut self,
491                            request: tonic::Request<tonic::Streaming<super::ClientEvent>>,
492                        ) -> Self::Future {
493                            let inner = Arc::clone(&self.0);
494                            let fut = async move {
495                                <T as SidecarSessionService>::open_control_session(
496                                        &inner,
497                                        request,
498                                    )
499                                    .await
500                            };
501                            Box::pin(fut)
502                        }
503                    }
504                    let accept_compression_encodings = self.accept_compression_encodings;
505                    let send_compression_encodings = self.send_compression_encodings;
506                    let max_decoding_message_size = self.max_decoding_message_size;
507                    let max_encoding_message_size = self.max_encoding_message_size;
508                    let inner = self.inner.clone();
509                    let fut = async move {
510                        let method = OpenControlSessionSvc(inner);
511                        let codec = tonic_prost::ProstCodec::default();
512                        let mut grpc = tonic::server::Grpc::new(codec)
513                            .apply_compression_config(
514                                accept_compression_encodings,
515                                send_compression_encodings,
516                            )
517                            .apply_max_message_size_config(
518                                max_decoding_message_size,
519                                max_encoding_message_size,
520                            );
521                        let res = grpc.streaming(method, req).await;
522                        Ok(res)
523                    };
524                    Box::pin(fut)
525                }
526                _ => {
527                    Box::pin(async move {
528                        let mut response = http::Response::new(
529                            tonic::body::Body::default(),
530                        );
531                        let headers = response.headers_mut();
532                        headers
533                            .insert(
534                                tonic::Status::GRPC_STATUS,
535                                (tonic::Code::Unimplemented as i32).into(),
536                            );
537                        headers
538                            .insert(
539                                http::header::CONTENT_TYPE,
540                                tonic::metadata::GRPC_CONTENT_TYPE,
541                            );
542                        Ok(response)
543                    })
544                }
545            }
546        }
547    }
548    impl<T> Clone for SidecarSessionServiceServer<T> {
549        fn clone(&self) -> Self {
550            let inner = self.inner.clone();
551            Self {
552                inner,
553                accept_compression_encodings: self.accept_compression_encodings,
554                send_compression_encodings: self.send_compression_encodings,
555                max_decoding_message_size: self.max_decoding_message_size,
556                max_encoding_message_size: self.max_encoding_message_size,
557            }
558        }
559    }
560    /// Generated gRPC service name
561    pub const SERVICE_NAME: &str = "pole.sidecar.v1.SidecarSessionService";
562    impl<T> tonic::server::NamedService for SidecarSessionServiceServer<T> {
563        const NAME: &'static str = SERVICE_NAME;
564    }
565}