risingwave_pb/
health.rs

1// This file is @generated by prost-build.
2#[derive(prost_helpers::AnyPB)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct HealthCheckRequest {
5    #[prost(string, tag = "1")]
6    pub service: ::prost::alloc::string::String,
7}
8#[derive(prost_helpers::AnyPB)]
9#[derive(Clone, Copy, PartialEq, ::prost::Message)]
10pub struct HealthCheckResponse {
11    #[prost(enumeration = "health_check_response::ServingStatus", tag = "1")]
12    pub status: i32,
13}
14/// Nested message and enum types in `HealthCheckResponse`.
15pub mod health_check_response {
16    #[derive(prost_helpers::AnyPB)]
17    #[derive(
18        Clone,
19        Copy,
20        Debug,
21        PartialEq,
22        Eq,
23        Hash,
24        PartialOrd,
25        Ord,
26        ::prost::Enumeration
27    )]
28    #[repr(i32)]
29    pub enum ServingStatus {
30        Unknown = 0,
31        Serving = 1,
32        NotServing = 2,
33    }
34    impl ServingStatus {
35        /// String value of the enum field names used in the ProtoBuf definition.
36        ///
37        /// The values are not transformed in any way and thus are considered stable
38        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
39        pub fn as_str_name(&self) -> &'static str {
40            match self {
41                Self::Unknown => "UNKNOWN",
42                Self::Serving => "SERVING",
43                Self::NotServing => "NOT_SERVING",
44            }
45        }
46        /// Creates an enum from field names used in the ProtoBuf definition.
47        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
48            match value {
49                "UNKNOWN" => Some(Self::Unknown),
50                "SERVING" => Some(Self::Serving),
51                "NOT_SERVING" => Some(Self::NotServing),
52                _ => None,
53            }
54        }
55    }
56}
57/// Generated client implementations.
58pub mod health_client {
59    #![allow(
60        unused_variables,
61        dead_code,
62        missing_docs,
63        clippy::wildcard_imports,
64        clippy::let_unit_value,
65    )]
66    use tonic::codegen::*;
67    use tonic::codegen::http::Uri;
68    #[derive(Debug, Clone)]
69    pub struct HealthClient<T> {
70        inner: tonic::client::Grpc<T>,
71    }
72    impl HealthClient<tonic::transport::Channel> {
73        /// Attempt to create a new client by connecting to a given endpoint.
74        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
75        where
76            D: TryInto<tonic::transport::Endpoint>,
77            D::Error: Into<StdError>,
78        {
79            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
80            Ok(Self::new(conn))
81        }
82    }
83    impl<T> HealthClient<T>
84    where
85        T: tonic::client::GrpcService<tonic::body::BoxBody>,
86        T::Error: Into<StdError>,
87        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
88        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
89    {
90        pub fn new(inner: T) -> Self {
91            let inner = tonic::client::Grpc::new(inner);
92            Self { inner }
93        }
94        pub fn with_origin(inner: T, origin: Uri) -> Self {
95            let inner = tonic::client::Grpc::with_origin(inner, origin);
96            Self { inner }
97        }
98        pub fn with_interceptor<F>(
99            inner: T,
100            interceptor: F,
101        ) -> HealthClient<InterceptedService<T, F>>
102        where
103            F: tonic::service::Interceptor,
104            T::ResponseBody: Default,
105            T: tonic::codegen::Service<
106                http::Request<tonic::body::BoxBody>,
107                Response = http::Response<
108                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
109                >,
110            >,
111            <T as tonic::codegen::Service<
112                http::Request<tonic::body::BoxBody>,
113            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
114        {
115            HealthClient::new(InterceptedService::new(inner, interceptor))
116        }
117        /// Compress requests with the given encoding.
118        ///
119        /// This requires the server to support it otherwise it might respond with an
120        /// error.
121        #[must_use]
122        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
123            self.inner = self.inner.send_compressed(encoding);
124            self
125        }
126        /// Enable decompressing responses.
127        #[must_use]
128        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
129            self.inner = self.inner.accept_compressed(encoding);
130            self
131        }
132        /// Limits the maximum size of a decoded message.
133        ///
134        /// Default: `4MB`
135        #[must_use]
136        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
137            self.inner = self.inner.max_decoding_message_size(limit);
138            self
139        }
140        /// Limits the maximum size of an encoded message.
141        ///
142        /// Default: `usize::MAX`
143        #[must_use]
144        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
145            self.inner = self.inner.max_encoding_message_size(limit);
146            self
147        }
148        pub async fn check(
149            &mut self,
150            request: impl tonic::IntoRequest<super::HealthCheckRequest>,
151        ) -> std::result::Result<
152            tonic::Response<super::HealthCheckResponse>,
153            tonic::Status,
154        > {
155            self.inner
156                .ready()
157                .await
158                .map_err(|e| {
159                    tonic::Status::unknown(
160                        format!("Service was not ready: {}", e.into()),
161                    )
162                })?;
163            let codec = tonic::codec::ProstCodec::default();
164            let path = http::uri::PathAndQuery::from_static("/health.Health/Check");
165            let mut req = request.into_request();
166            req.extensions_mut().insert(GrpcMethod::new("health.Health", "Check"));
167            self.inner.unary(req, path, codec).await
168        }
169    }
170}
171/// Generated server implementations.
172pub mod health_server {
173    #![allow(
174        unused_variables,
175        dead_code,
176        missing_docs,
177        clippy::wildcard_imports,
178        clippy::let_unit_value,
179    )]
180    use tonic::codegen::*;
181    /// Generated trait containing gRPC methods that should be implemented for use with HealthServer.
182    #[async_trait]
183    pub trait Health: std::marker::Send + std::marker::Sync + 'static {
184        async fn check(
185            &self,
186            request: tonic::Request<super::HealthCheckRequest>,
187        ) -> std::result::Result<
188            tonic::Response<super::HealthCheckResponse>,
189            tonic::Status,
190        >;
191    }
192    #[derive(Debug)]
193    pub struct HealthServer<T> {
194        inner: Arc<T>,
195        accept_compression_encodings: EnabledCompressionEncodings,
196        send_compression_encodings: EnabledCompressionEncodings,
197        max_decoding_message_size: Option<usize>,
198        max_encoding_message_size: Option<usize>,
199    }
200    impl<T> HealthServer<T> {
201        pub fn new(inner: T) -> Self {
202            Self::from_arc(Arc::new(inner))
203        }
204        pub fn from_arc(inner: Arc<T>) -> Self {
205            Self {
206                inner,
207                accept_compression_encodings: Default::default(),
208                send_compression_encodings: Default::default(),
209                max_decoding_message_size: None,
210                max_encoding_message_size: None,
211            }
212        }
213        pub fn with_interceptor<F>(
214            inner: T,
215            interceptor: F,
216        ) -> InterceptedService<Self, F>
217        where
218            F: tonic::service::Interceptor,
219        {
220            InterceptedService::new(Self::new(inner), interceptor)
221        }
222        /// Enable decompressing requests with the given encoding.
223        #[must_use]
224        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
225            self.accept_compression_encodings.enable(encoding);
226            self
227        }
228        /// Compress responses with the given encoding, if the client supports it.
229        #[must_use]
230        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
231            self.send_compression_encodings.enable(encoding);
232            self
233        }
234        /// Limits the maximum size of a decoded message.
235        ///
236        /// Default: `4MB`
237        #[must_use]
238        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
239            self.max_decoding_message_size = Some(limit);
240            self
241        }
242        /// Limits the maximum size of an encoded message.
243        ///
244        /// Default: `usize::MAX`
245        #[must_use]
246        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
247            self.max_encoding_message_size = Some(limit);
248            self
249        }
250    }
251    impl<T, B> tonic::codegen::Service<http::Request<B>> for HealthServer<T>
252    where
253        T: Health,
254        B: Body + std::marker::Send + 'static,
255        B::Error: Into<StdError> + std::marker::Send + 'static,
256    {
257        type Response = http::Response<tonic::body::BoxBody>;
258        type Error = std::convert::Infallible;
259        type Future = BoxFuture<Self::Response, Self::Error>;
260        fn poll_ready(
261            &mut self,
262            _cx: &mut Context<'_>,
263        ) -> Poll<std::result::Result<(), Self::Error>> {
264            Poll::Ready(Ok(()))
265        }
266        fn call(&mut self, req: http::Request<B>) -> Self::Future {
267            match req.uri().path() {
268                "/health.Health/Check" => {
269                    #[allow(non_camel_case_types)]
270                    struct CheckSvc<T: Health>(pub Arc<T>);
271                    impl<
272                        T: Health,
273                    > tonic::server::UnaryService<super::HealthCheckRequest>
274                    for CheckSvc<T> {
275                        type Response = super::HealthCheckResponse;
276                        type Future = BoxFuture<
277                            tonic::Response<Self::Response>,
278                            tonic::Status,
279                        >;
280                        fn call(
281                            &mut self,
282                            request: tonic::Request<super::HealthCheckRequest>,
283                        ) -> Self::Future {
284                            let inner = Arc::clone(&self.0);
285                            let fut = async move {
286                                <T as Health>::check(&inner, request).await
287                            };
288                            Box::pin(fut)
289                        }
290                    }
291                    let accept_compression_encodings = self.accept_compression_encodings;
292                    let send_compression_encodings = self.send_compression_encodings;
293                    let max_decoding_message_size = self.max_decoding_message_size;
294                    let max_encoding_message_size = self.max_encoding_message_size;
295                    let inner = self.inner.clone();
296                    let fut = async move {
297                        let method = CheckSvc(inner);
298                        let codec = tonic::codec::ProstCodec::default();
299                        let mut grpc = tonic::server::Grpc::new(codec)
300                            .apply_compression_config(
301                                accept_compression_encodings,
302                                send_compression_encodings,
303                            )
304                            .apply_max_message_size_config(
305                                max_decoding_message_size,
306                                max_encoding_message_size,
307                            );
308                        let res = grpc.unary(method, req).await;
309                        Ok(res)
310                    };
311                    Box::pin(fut)
312                }
313                _ => {
314                    Box::pin(async move {
315                        let mut response = http::Response::new(empty_body());
316                        let headers = response.headers_mut();
317                        headers
318                            .insert(
319                                tonic::Status::GRPC_STATUS,
320                                (tonic::Code::Unimplemented as i32).into(),
321                            );
322                        headers
323                            .insert(
324                                http::header::CONTENT_TYPE,
325                                tonic::metadata::GRPC_CONTENT_TYPE,
326                            );
327                        Ok(response)
328                    })
329                }
330            }
331        }
332    }
333    impl<T> Clone for HealthServer<T> {
334        fn clone(&self) -> Self {
335            let inner = self.inner.clone();
336            Self {
337                inner,
338                accept_compression_encodings: self.accept_compression_encodings,
339                send_compression_encodings: self.send_compression_encodings,
340                max_decoding_message_size: self.max_decoding_message_size,
341                max_encoding_message_size: self.max_encoding_message_size,
342            }
343        }
344    }
345    /// Generated gRPC service name
346    pub const SERVICE_NAME: &str = "health.Health";
347    impl<T> tonic::server::NamedService for HealthServer<T> {
348        const NAME: &'static str = SERVICE_NAME;
349    }
350}