1pub mod future_service_client {
4 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
5 use tonic::codegen::*;
6 use tonic::codegen::http::Uri;
7 #[derive(Debug, Clone)]
8 pub struct FutureServiceClient<T> {
9 inner: tonic::client::Grpc<T>,
10 }
11 impl FutureServiceClient<tonic::transport::Channel> {
12 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
14 where
15 D: TryInto<tonic::transport::Endpoint>,
16 D::Error: Into<StdError>,
17 {
18 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
19 Ok(Self::new(conn))
20 }
21 }
22 impl<T> FutureServiceClient<T>
23 where
24 T: tonic::client::GrpcService<tonic::body::BoxBody>,
25 T::Error: Into<StdError>,
26 T::ResponseBody: Body<Data = Bytes> + Send + 'static,
27 <T::ResponseBody as Body>::Error: Into<StdError> + Send,
28 {
29 pub fn new(inner: T) -> Self {
30 let inner = tonic::client::Grpc::new(inner);
31 Self { inner }
32 }
33 pub fn with_origin(inner: T, origin: Uri) -> Self {
34 let inner = tonic::client::Grpc::with_origin(inner, origin);
35 Self { inner }
36 }
37 pub fn with_interceptor<F>(
38 inner: T,
39 interceptor: F,
40 ) -> FutureServiceClient<InterceptedService<T, F>>
41 where
42 F: tonic::service::Interceptor,
43 T::ResponseBody: Default,
44 T: tonic::codegen::Service<
45 http::Request<tonic::body::BoxBody>,
46 Response = http::Response<
47 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
48 >,
49 >,
50 <T as tonic::codegen::Service<
51 http::Request<tonic::body::BoxBody>,
52 >>::Error: Into<StdError> + Send + Sync,
53 {
54 FutureServiceClient::new(InterceptedService::new(inner, interceptor))
55 }
56 #[must_use]
61 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
62 self.inner = self.inner.send_compressed(encoding);
63 self
64 }
65 #[must_use]
67 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
68 self.inner = self.inner.accept_compressed(encoding);
69 self
70 }
71 #[must_use]
75 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
76 self.inner = self.inner.max_decoding_message_size(limit);
77 self
78 }
79 #[must_use]
83 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
84 self.inner = self.inner.max_encoding_message_size(limit);
85 self
86 }
87 pub async fn get_future(
88 &mut self,
89 request: impl tonic::IntoRequest<super::GetFutureRequest>,
90 ) -> std::result::Result<tonic::Response<super::Future>, tonic::Status> {
91 self.inner
92 .ready()
93 .await
94 .map_err(|e| {
95 tonic::Status::new(
96 tonic::Code::Unknown,
97 format!("Service was not ready: {}", e.into()),
98 )
99 })?;
100 let codec = tonic::codec::ProstCodec::default();
101 let path = http::uri::PathAndQuery::from_static(
102 "/kdo.v1.future.FutureService/GetFuture",
103 );
104 let mut req = request.into_request();
105 req.extensions_mut()
106 .insert(GrpcMethod::new("kdo.v1.future.FutureService", "GetFuture"));
107 self.inner.unary(req, path, codec).await
108 }
109 pub async fn list_futures(
110 &mut self,
111 request: impl tonic::IntoRequest<super::ListFuturesRequest>,
112 ) -> std::result::Result<
113 tonic::Response<super::ListFuturesResponse>,
114 tonic::Status,
115 > {
116 self.inner
117 .ready()
118 .await
119 .map_err(|e| {
120 tonic::Status::new(
121 tonic::Code::Unknown,
122 format!("Service was not ready: {}", e.into()),
123 )
124 })?;
125 let codec = tonic::codec::ProstCodec::default();
126 let path = http::uri::PathAndQuery::from_static(
127 "/kdo.v1.future.FutureService/ListFutures",
128 );
129 let mut req = request.into_request();
130 req.extensions_mut()
131 .insert(GrpcMethod::new("kdo.v1.future.FutureService", "ListFutures"));
132 self.inner.unary(req, path, codec).await
133 }
134 }
135}
136pub mod future_service_server {
138 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
139 use tonic::codegen::*;
140 #[async_trait]
142 pub trait FutureService: Send + Sync + 'static {
143 async fn get_future(
144 &self,
145 request: tonic::Request<super::GetFutureRequest>,
146 ) -> std::result::Result<tonic::Response<super::Future>, tonic::Status>;
147 async fn list_futures(
148 &self,
149 request: tonic::Request<super::ListFuturesRequest>,
150 ) -> std::result::Result<
151 tonic::Response<super::ListFuturesResponse>,
152 tonic::Status,
153 >;
154 }
155 #[derive(Debug)]
156 pub struct FutureServiceServer<T: FutureService> {
157 inner: Arc<T>,
158 accept_compression_encodings: EnabledCompressionEncodings,
159 send_compression_encodings: EnabledCompressionEncodings,
160 max_decoding_message_size: Option<usize>,
161 max_encoding_message_size: Option<usize>,
162 }
163 impl<T: FutureService> FutureServiceServer<T> {
164 pub fn new(inner: T) -> Self {
165 Self::from_arc(Arc::new(inner))
166 }
167 pub fn from_arc(inner: Arc<T>) -> Self {
168 Self {
169 inner,
170 accept_compression_encodings: Default::default(),
171 send_compression_encodings: Default::default(),
172 max_decoding_message_size: None,
173 max_encoding_message_size: None,
174 }
175 }
176 pub fn with_interceptor<F>(
177 inner: T,
178 interceptor: F,
179 ) -> InterceptedService<Self, F>
180 where
181 F: tonic::service::Interceptor,
182 {
183 InterceptedService::new(Self::new(inner), interceptor)
184 }
185 #[must_use]
187 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
188 self.accept_compression_encodings.enable(encoding);
189 self
190 }
191 #[must_use]
193 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
194 self.send_compression_encodings.enable(encoding);
195 self
196 }
197 #[must_use]
201 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
202 self.max_decoding_message_size = Some(limit);
203 self
204 }
205 #[must_use]
209 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
210 self.max_encoding_message_size = Some(limit);
211 self
212 }
213 }
214 impl<T, B> tonic::codegen::Service<http::Request<B>> for FutureServiceServer<T>
215 where
216 T: FutureService,
217 B: Body + Send + 'static,
218 B::Error: Into<StdError> + Send + 'static,
219 {
220 type Response = http::Response<tonic::body::BoxBody>;
221 type Error = std::convert::Infallible;
222 type Future = BoxFuture<Self::Response, Self::Error>;
223 fn poll_ready(
224 &mut self,
225 _cx: &mut Context<'_>,
226 ) -> Poll<std::result::Result<(), Self::Error>> {
227 Poll::Ready(Ok(()))
228 }
229 fn call(&mut self, req: http::Request<B>) -> Self::Future {
230 match req.uri().path() {
231 "/kdo.v1.future.FutureService/GetFuture" => {
232 #[allow(non_camel_case_types)]
233 struct GetFutureSvc<T: FutureService>(pub Arc<T>);
234 impl<
235 T: FutureService,
236 > tonic::server::UnaryService<super::GetFutureRequest>
237 for GetFutureSvc<T> {
238 type Response = super::Future;
239 type Future = BoxFuture<
240 tonic::Response<Self::Response>,
241 tonic::Status,
242 >;
243 fn call(
244 &mut self,
245 request: tonic::Request<super::GetFutureRequest>,
246 ) -> Self::Future {
247 let inner = Arc::clone(&self.0);
248 let fut = async move {
249 <T as FutureService>::get_future(&inner, request).await
250 };
251 Box::pin(fut)
252 }
253 }
254 let accept_compression_encodings = self.accept_compression_encodings;
255 let send_compression_encodings = self.send_compression_encodings;
256 let max_decoding_message_size = self.max_decoding_message_size;
257 let max_encoding_message_size = self.max_encoding_message_size;
258 let inner = self.inner.clone();
259 let fut = async move {
260 let method = GetFutureSvc(inner);
261 let codec = tonic::codec::ProstCodec::default();
262 let mut grpc = tonic::server::Grpc::new(codec)
263 .apply_compression_config(
264 accept_compression_encodings,
265 send_compression_encodings,
266 )
267 .apply_max_message_size_config(
268 max_decoding_message_size,
269 max_encoding_message_size,
270 );
271 let res = grpc.unary(method, req).await;
272 Ok(res)
273 };
274 Box::pin(fut)
275 }
276 "/kdo.v1.future.FutureService/ListFutures" => {
277 #[allow(non_camel_case_types)]
278 struct ListFuturesSvc<T: FutureService>(pub Arc<T>);
279 impl<
280 T: FutureService,
281 > tonic::server::UnaryService<super::ListFuturesRequest>
282 for ListFuturesSvc<T> {
283 type Response = super::ListFuturesResponse;
284 type Future = BoxFuture<
285 tonic::Response<Self::Response>,
286 tonic::Status,
287 >;
288 fn call(
289 &mut self,
290 request: tonic::Request<super::ListFuturesRequest>,
291 ) -> Self::Future {
292 let inner = Arc::clone(&self.0);
293 let fut = async move {
294 <T as FutureService>::list_futures(&inner, request).await
295 };
296 Box::pin(fut)
297 }
298 }
299 let accept_compression_encodings = self.accept_compression_encodings;
300 let send_compression_encodings = self.send_compression_encodings;
301 let max_decoding_message_size = self.max_decoding_message_size;
302 let max_encoding_message_size = self.max_encoding_message_size;
303 let inner = self.inner.clone();
304 let fut = async move {
305 let method = ListFuturesSvc(inner);
306 let codec = tonic::codec::ProstCodec::default();
307 let mut grpc = tonic::server::Grpc::new(codec)
308 .apply_compression_config(
309 accept_compression_encodings,
310 send_compression_encodings,
311 )
312 .apply_max_message_size_config(
313 max_decoding_message_size,
314 max_encoding_message_size,
315 );
316 let res = grpc.unary(method, req).await;
317 Ok(res)
318 };
319 Box::pin(fut)
320 }
321 _ => {
322 Box::pin(async move {
323 Ok(
324 http::Response::builder()
325 .status(200)
326 .header("grpc-status", tonic::Code::Unimplemented as i32)
327 .header(
328 http::header::CONTENT_TYPE,
329 tonic::metadata::GRPC_CONTENT_TYPE,
330 )
331 .body(empty_body())
332 .unwrap(),
333 )
334 })
335 }
336 }
337 }
338 }
339 impl<T: FutureService> Clone for FutureServiceServer<T> {
340 fn clone(&self) -> Self {
341 let inner = self.inner.clone();
342 Self {
343 inner,
344 accept_compression_encodings: self.accept_compression_encodings,
345 send_compression_encodings: self.send_compression_encodings,
346 max_decoding_message_size: self.max_decoding_message_size,
347 max_encoding_message_size: self.max_encoding_message_size,
348 }
349 }
350 }
351 impl<T: FutureService> tonic::server::NamedService for FutureServiceServer<T> {
352 const NAME: &'static str = "kdo.v1.future.FutureService";
353 }
354}