subliminal_protos_rust/codegen/
service_registry.rs

1#[allow(clippy::derive_partial_eq_without_eq)]
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct RegisterServiceRequest {
4    #[prost(string, tag = "1")]
5    pub service_name: ::prost::alloc::string::String,
6    #[prost(string, tag = "2")]
7    pub service_address: ::prost::alloc::string::String,
8    #[prost(string, tag = "3")]
9    pub service_port: ::prost::alloc::string::String,
10}
11#[allow(clippy::derive_partial_eq_without_eq)]
12#[derive(Clone, PartialEq, ::prost::Message)]
13pub struct RegisterServiceResponse {
14    #[prost(bool, tag = "1")]
15    pub success: bool,
16}
17#[allow(clippy::derive_partial_eq_without_eq)]
18#[derive(Clone, PartialEq, ::prost::Message)]
19pub struct UnregisterServiceRequest {
20    #[prost(string, tag = "1")]
21    pub service_name: ::prost::alloc::string::String,
22    #[prost(string, tag = "2")]
23    pub service_address: ::prost::alloc::string::String,
24    #[prost(string, tag = "3")]
25    pub service_port: ::prost::alloc::string::String,
26}
27#[allow(clippy::derive_partial_eq_without_eq)]
28#[derive(Clone, PartialEq, ::prost::Message)]
29pub struct UnregisterServiceResponse {
30    #[prost(bool, tag = "1")]
31    pub success: bool,
32}
33#[allow(clippy::derive_partial_eq_without_eq)]
34#[derive(Clone, PartialEq, ::prost::Message)]
35pub struct GetServiceRequest {
36    #[prost(string, tag = "1")]
37    pub service_name: ::prost::alloc::string::String,
38}
39#[allow(clippy::derive_partial_eq_without_eq)]
40#[derive(Clone, PartialEq, ::prost::Message)]
41pub struct GetServiceResponse {
42    #[prost(string, tag = "1")]
43    pub service_address: ::prost::alloc::string::String,
44    #[prost(string, tag = "2")]
45    pub service_port: ::prost::alloc::string::String,
46}
47/// Generated client implementations.
48pub mod service_registry_client {
49    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
50    use tonic::codegen::*;
51    use tonic::codegen::http::Uri;
52    #[derive(Debug, Clone)]
53    pub struct ServiceRegistryClient<T> {
54        inner: tonic::client::Grpc<T>,
55    }
56    impl ServiceRegistryClient<tonic::transport::Channel> {
57        /// Attempt to create a new client by connecting to a given endpoint.
58        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
59        where
60            D: std::convert::TryInto<tonic::transport::Endpoint>,
61            D::Error: Into<StdError>,
62        {
63            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
64            Ok(Self::new(conn))
65        }
66    }
67    impl<T> ServiceRegistryClient<T>
68    where
69        T: tonic::client::GrpcService<tonic::body::BoxBody>,
70        T::Error: Into<StdError>,
71        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
72        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
73    {
74        pub fn new(inner: T) -> Self {
75            let inner = tonic::client::Grpc::new(inner);
76            Self { inner }
77        }
78        pub fn with_origin(inner: T, origin: Uri) -> Self {
79            let inner = tonic::client::Grpc::with_origin(inner, origin);
80            Self { inner }
81        }
82        pub fn with_interceptor<F>(
83            inner: T,
84            interceptor: F,
85        ) -> ServiceRegistryClient<InterceptedService<T, F>>
86        where
87            F: tonic::service::Interceptor,
88            T::ResponseBody: Default,
89            T: tonic::codegen::Service<
90                http::Request<tonic::body::BoxBody>,
91                Response = http::Response<
92                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
93                >,
94            >,
95            <T as tonic::codegen::Service<
96                http::Request<tonic::body::BoxBody>,
97            >>::Error: Into<StdError> + Send + Sync,
98        {
99            ServiceRegistryClient::new(InterceptedService::new(inner, interceptor))
100        }
101        /// Compress requests with the given encoding.
102        ///
103        /// This requires the server to support it otherwise it might respond with an
104        /// error.
105        #[must_use]
106        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
107            self.inner = self.inner.send_compressed(encoding);
108            self
109        }
110        /// Enable decompressing responses.
111        #[must_use]
112        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
113            self.inner = self.inner.accept_compressed(encoding);
114            self
115        }
116        pub async fn register_service(
117            &mut self,
118            request: impl tonic::IntoRequest<super::RegisterServiceRequest>,
119        ) -> Result<tonic::Response<super::RegisterServiceResponse>, tonic::Status> {
120            self.inner
121                .ready()
122                .await
123                .map_err(|e| {
124                    tonic::Status::new(
125                        tonic::Code::Unknown,
126                        format!("Service was not ready: {}", e.into()),
127                    )
128                })?;
129            let codec = tonic::codec::ProstCodec::default();
130            let path = http::uri::PathAndQuery::from_static(
131                "/service_registry.ServiceRegistry/RegisterService",
132            );
133            self.inner.unary(request.into_request(), path, codec).await
134        }
135        pub async fn unregister_service(
136            &mut self,
137            request: impl tonic::IntoRequest<super::UnregisterServiceRequest>,
138        ) -> Result<tonic::Response<super::UnregisterServiceResponse>, tonic::Status> {
139            self.inner
140                .ready()
141                .await
142                .map_err(|e| {
143                    tonic::Status::new(
144                        tonic::Code::Unknown,
145                        format!("Service was not ready: {}", e.into()),
146                    )
147                })?;
148            let codec = tonic::codec::ProstCodec::default();
149            let path = http::uri::PathAndQuery::from_static(
150                "/service_registry.ServiceRegistry/UnregisterService",
151            );
152            self.inner.unary(request.into_request(), path, codec).await
153        }
154        pub async fn get_service(
155            &mut self,
156            request: impl tonic::IntoRequest<super::GetServiceRequest>,
157        ) -> Result<tonic::Response<super::GetServiceResponse>, tonic::Status> {
158            self.inner
159                .ready()
160                .await
161                .map_err(|e| {
162                    tonic::Status::new(
163                        tonic::Code::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                "/service_registry.ServiceRegistry/GetService",
170            );
171            self.inner.unary(request.into_request(), path, codec).await
172        }
173    }
174}
175/// Generated server implementations.
176pub mod service_registry_server {
177    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
178    use tonic::codegen::*;
179    /// Generated trait containing gRPC methods that should be implemented for use with ServiceRegistryServer.
180    #[async_trait]
181    pub trait ServiceRegistry: Send + Sync + 'static {
182        async fn register_service(
183            &self,
184            request: tonic::Request<super::RegisterServiceRequest>,
185        ) -> Result<tonic::Response<super::RegisterServiceResponse>, tonic::Status>;
186        async fn unregister_service(
187            &self,
188            request: tonic::Request<super::UnregisterServiceRequest>,
189        ) -> Result<tonic::Response<super::UnregisterServiceResponse>, tonic::Status>;
190        async fn get_service(
191            &self,
192            request: tonic::Request<super::GetServiceRequest>,
193        ) -> Result<tonic::Response<super::GetServiceResponse>, tonic::Status>;
194    }
195    #[derive(Debug)]
196    pub struct ServiceRegistryServer<T: ServiceRegistry> {
197        inner: _Inner<T>,
198        accept_compression_encodings: EnabledCompressionEncodings,
199        send_compression_encodings: EnabledCompressionEncodings,
200    }
201    struct _Inner<T>(Arc<T>);
202    impl<T: ServiceRegistry> ServiceRegistryServer<T> {
203        pub fn new(inner: T) -> Self {
204            Self::from_arc(Arc::new(inner))
205        }
206        pub fn from_arc(inner: Arc<T>) -> Self {
207            let inner = _Inner(inner);
208            Self {
209                inner,
210                accept_compression_encodings: Default::default(),
211                send_compression_encodings: Default::default(),
212            }
213        }
214        pub fn with_interceptor<F>(
215            inner: T,
216            interceptor: F,
217        ) -> InterceptedService<Self, F>
218        where
219            F: tonic::service::Interceptor,
220        {
221            InterceptedService::new(Self::new(inner), interceptor)
222        }
223        /// Enable decompressing requests with the given encoding.
224        #[must_use]
225        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
226            self.accept_compression_encodings.enable(encoding);
227            self
228        }
229        /// Compress responses with the given encoding, if the client supports it.
230        #[must_use]
231        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
232            self.send_compression_encodings.enable(encoding);
233            self
234        }
235    }
236    impl<T, B> tonic::codegen::Service<http::Request<B>> for ServiceRegistryServer<T>
237    where
238        T: ServiceRegistry,
239        B: Body + Send + 'static,
240        B::Error: Into<StdError> + Send + 'static,
241    {
242        type Response = http::Response<tonic::body::BoxBody>;
243        type Error = std::convert::Infallible;
244        type Future = BoxFuture<Self::Response, Self::Error>;
245        fn poll_ready(
246            &mut self,
247            _cx: &mut Context<'_>,
248        ) -> Poll<Result<(), Self::Error>> {
249            Poll::Ready(Ok(()))
250        }
251        fn call(&mut self, req: http::Request<B>) -> Self::Future {
252            let inner = self.inner.clone();
253            match req.uri().path() {
254                "/service_registry.ServiceRegistry/RegisterService" => {
255                    #[allow(non_camel_case_types)]
256                    struct RegisterServiceSvc<T: ServiceRegistry>(pub Arc<T>);
257                    impl<
258                        T: ServiceRegistry,
259                    > tonic::server::UnaryService<super::RegisterServiceRequest>
260                    for RegisterServiceSvc<T> {
261                        type Response = super::RegisterServiceResponse;
262                        type Future = BoxFuture<
263                            tonic::Response<Self::Response>,
264                            tonic::Status,
265                        >;
266                        fn call(
267                            &mut self,
268                            request: tonic::Request<super::RegisterServiceRequest>,
269                        ) -> Self::Future {
270                            let inner = self.0.clone();
271                            let fut = async move {
272                                (*inner).register_service(request).await
273                            };
274                            Box::pin(fut)
275                        }
276                    }
277                    let accept_compression_encodings = self.accept_compression_encodings;
278                    let send_compression_encodings = self.send_compression_encodings;
279                    let inner = self.inner.clone();
280                    let fut = async move {
281                        let inner = inner.0;
282                        let method = RegisterServiceSvc(inner);
283                        let codec = tonic::codec::ProstCodec::default();
284                        let mut grpc = tonic::server::Grpc::new(codec)
285                            .apply_compression_config(
286                                accept_compression_encodings,
287                                send_compression_encodings,
288                            );
289                        let res = grpc.unary(method, req).await;
290                        Ok(res)
291                    };
292                    Box::pin(fut)
293                }
294                "/service_registry.ServiceRegistry/UnregisterService" => {
295                    #[allow(non_camel_case_types)]
296                    struct UnregisterServiceSvc<T: ServiceRegistry>(pub Arc<T>);
297                    impl<
298                        T: ServiceRegistry,
299                    > tonic::server::UnaryService<super::UnregisterServiceRequest>
300                    for UnregisterServiceSvc<T> {
301                        type Response = super::UnregisterServiceResponse;
302                        type Future = BoxFuture<
303                            tonic::Response<Self::Response>,
304                            tonic::Status,
305                        >;
306                        fn call(
307                            &mut self,
308                            request: tonic::Request<super::UnregisterServiceRequest>,
309                        ) -> Self::Future {
310                            let inner = self.0.clone();
311                            let fut = async move {
312                                (*inner).unregister_service(request).await
313                            };
314                            Box::pin(fut)
315                        }
316                    }
317                    let accept_compression_encodings = self.accept_compression_encodings;
318                    let send_compression_encodings = self.send_compression_encodings;
319                    let inner = self.inner.clone();
320                    let fut = async move {
321                        let inner = inner.0;
322                        let method = UnregisterServiceSvc(inner);
323                        let codec = tonic::codec::ProstCodec::default();
324                        let mut grpc = tonic::server::Grpc::new(codec)
325                            .apply_compression_config(
326                                accept_compression_encodings,
327                                send_compression_encodings,
328                            );
329                        let res = grpc.unary(method, req).await;
330                        Ok(res)
331                    };
332                    Box::pin(fut)
333                }
334                "/service_registry.ServiceRegistry/GetService" => {
335                    #[allow(non_camel_case_types)]
336                    struct GetServiceSvc<T: ServiceRegistry>(pub Arc<T>);
337                    impl<
338                        T: ServiceRegistry,
339                    > tonic::server::UnaryService<super::GetServiceRequest>
340                    for GetServiceSvc<T> {
341                        type Response = super::GetServiceResponse;
342                        type Future = BoxFuture<
343                            tonic::Response<Self::Response>,
344                            tonic::Status,
345                        >;
346                        fn call(
347                            &mut self,
348                            request: tonic::Request<super::GetServiceRequest>,
349                        ) -> Self::Future {
350                            let inner = self.0.clone();
351                            let fut = async move { (*inner).get_service(request).await };
352                            Box::pin(fut)
353                        }
354                    }
355                    let accept_compression_encodings = self.accept_compression_encodings;
356                    let send_compression_encodings = self.send_compression_encodings;
357                    let inner = self.inner.clone();
358                    let fut = async move {
359                        let inner = inner.0;
360                        let method = GetServiceSvc(inner);
361                        let codec = tonic::codec::ProstCodec::default();
362                        let mut grpc = tonic::server::Grpc::new(codec)
363                            .apply_compression_config(
364                                accept_compression_encodings,
365                                send_compression_encodings,
366                            );
367                        let res = grpc.unary(method, req).await;
368                        Ok(res)
369                    };
370                    Box::pin(fut)
371                }
372                _ => {
373                    Box::pin(async move {
374                        Ok(
375                            http::Response::builder()
376                                .status(200)
377                                .header("grpc-status", "12")
378                                .header("content-type", "application/grpc")
379                                .body(empty_body())
380                                .unwrap(),
381                        )
382                    })
383                }
384            }
385        }
386    }
387    impl<T: ServiceRegistry> Clone for ServiceRegistryServer<T> {
388        fn clone(&self) -> Self {
389            let inner = self.inner.clone();
390            Self {
391                inner,
392                accept_compression_encodings: self.accept_compression_encodings,
393                send_compression_encodings: self.send_compression_encodings,
394            }
395        }
396    }
397    impl<T: ServiceRegistry> Clone for _Inner<T> {
398        fn clone(&self) -> Self {
399            Self(self.0.clone())
400        }
401    }
402    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
403        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
404            write!(f, "{:?}", self.0)
405        }
406    }
407    impl<T: ServiceRegistry> tonic::server::NamedService for ServiceRegistryServer<T> {
408        const NAME: &'static str = "service_registry.ServiceRegistry";
409    }
410}