1pub mod notification_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 NotificationServiceClient<T> {
9 inner: tonic::client::Grpc<T>,
10 }
11 impl NotificationServiceClient<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> NotificationServiceClient<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 ) -> NotificationServiceClient<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 NotificationServiceClient::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 list_notifications(
88 &mut self,
89 request: impl tonic::IntoRequest<super::ListNotificationsRequest>,
90 ) -> std::result::Result<
91 tonic::Response<super::ListNotificationsResponse>,
92 tonic::Status,
93 > {
94 self.inner
95 .ready()
96 .await
97 .map_err(|e| {
98 tonic::Status::new(
99 tonic::Code::Unknown,
100 format!("Service was not ready: {}", e.into()),
101 )
102 })?;
103 let codec = tonic::codec::ProstCodec::default();
104 let path = http::uri::PathAndQuery::from_static(
105 "/kdo.v1.notification.NotificationService/ListNotifications",
106 );
107 let mut req = request.into_request();
108 req.extensions_mut()
109 .insert(
110 GrpcMethod::new(
111 "kdo.v1.notification.NotificationService",
112 "ListNotifications",
113 ),
114 );
115 self.inner.unary(req, path, codec).await
116 }
117 pub async fn subscribe_notifications(
118 &mut self,
119 request: impl tonic::IntoRequest<super::SubscribeNotificationsRequest>,
120 ) -> std::result::Result<
121 tonic::Response<tonic::codec::Streaming<super::Notification>>,
122 tonic::Status,
123 > {
124 self.inner
125 .ready()
126 .await
127 .map_err(|e| {
128 tonic::Status::new(
129 tonic::Code::Unknown,
130 format!("Service was not ready: {}", e.into()),
131 )
132 })?;
133 let codec = tonic::codec::ProstCodec::default();
134 let path = http::uri::PathAndQuery::from_static(
135 "/kdo.v1.notification.NotificationService/SubscribeNotifications",
136 );
137 let mut req = request.into_request();
138 req.extensions_mut()
139 .insert(
140 GrpcMethod::new(
141 "kdo.v1.notification.NotificationService",
142 "SubscribeNotifications",
143 ),
144 );
145 self.inner.server_streaming(req, path, codec).await
146 }
147 pub async fn acknowledge_notification(
148 &mut self,
149 request: impl tonic::IntoRequest<super::AcknowledgeNotificationRequest>,
150 ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
151 self.inner
152 .ready()
153 .await
154 .map_err(|e| {
155 tonic::Status::new(
156 tonic::Code::Unknown,
157 format!("Service was not ready: {}", e.into()),
158 )
159 })?;
160 let codec = tonic::codec::ProstCodec::default();
161 let path = http::uri::PathAndQuery::from_static(
162 "/kdo.v1.notification.NotificationService/AcknowledgeNotification",
163 );
164 let mut req = request.into_request();
165 req.extensions_mut()
166 .insert(
167 GrpcMethod::new(
168 "kdo.v1.notification.NotificationService",
169 "AcknowledgeNotification",
170 ),
171 );
172 self.inner.unary(req, path, codec).await
173 }
174 }
175}
176pub mod notification_service_server {
178 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
179 use tonic::codegen::*;
180 #[async_trait]
182 pub trait NotificationService: Send + Sync + 'static {
183 async fn list_notifications(
184 &self,
185 request: tonic::Request<super::ListNotificationsRequest>,
186 ) -> std::result::Result<
187 tonic::Response<super::ListNotificationsResponse>,
188 tonic::Status,
189 >;
190 type SubscribeNotificationsStream: tonic::codegen::tokio_stream::Stream<
192 Item = std::result::Result<super::Notification, tonic::Status>,
193 >
194 + Send
195 + 'static;
196 async fn subscribe_notifications(
197 &self,
198 request: tonic::Request<super::SubscribeNotificationsRequest>,
199 ) -> std::result::Result<
200 tonic::Response<Self::SubscribeNotificationsStream>,
201 tonic::Status,
202 >;
203 async fn acknowledge_notification(
204 &self,
205 request: tonic::Request<super::AcknowledgeNotificationRequest>,
206 ) -> std::result::Result<tonic::Response<()>, tonic::Status>;
207 }
208 #[derive(Debug)]
209 pub struct NotificationServiceServer<T: NotificationService> {
210 inner: Arc<T>,
211 accept_compression_encodings: EnabledCompressionEncodings,
212 send_compression_encodings: EnabledCompressionEncodings,
213 max_decoding_message_size: Option<usize>,
214 max_encoding_message_size: Option<usize>,
215 }
216 impl<T: NotificationService> NotificationServiceServer<T> {
217 pub fn new(inner: T) -> Self {
218 Self::from_arc(Arc::new(inner))
219 }
220 pub fn from_arc(inner: Arc<T>) -> Self {
221 Self {
222 inner,
223 accept_compression_encodings: Default::default(),
224 send_compression_encodings: Default::default(),
225 max_decoding_message_size: None,
226 max_encoding_message_size: None,
227 }
228 }
229 pub fn with_interceptor<F>(
230 inner: T,
231 interceptor: F,
232 ) -> InterceptedService<Self, F>
233 where
234 F: tonic::service::Interceptor,
235 {
236 InterceptedService::new(Self::new(inner), interceptor)
237 }
238 #[must_use]
240 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
241 self.accept_compression_encodings.enable(encoding);
242 self
243 }
244 #[must_use]
246 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
247 self.send_compression_encodings.enable(encoding);
248 self
249 }
250 #[must_use]
254 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
255 self.max_decoding_message_size = Some(limit);
256 self
257 }
258 #[must_use]
262 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
263 self.max_encoding_message_size = Some(limit);
264 self
265 }
266 }
267 impl<T, B> tonic::codegen::Service<http::Request<B>> for NotificationServiceServer<T>
268 where
269 T: NotificationService,
270 B: Body + Send + 'static,
271 B::Error: Into<StdError> + Send + 'static,
272 {
273 type Response = http::Response<tonic::body::BoxBody>;
274 type Error = std::convert::Infallible;
275 type Future = BoxFuture<Self::Response, Self::Error>;
276 fn poll_ready(
277 &mut self,
278 _cx: &mut Context<'_>,
279 ) -> Poll<std::result::Result<(), Self::Error>> {
280 Poll::Ready(Ok(()))
281 }
282 fn call(&mut self, req: http::Request<B>) -> Self::Future {
283 match req.uri().path() {
284 "/kdo.v1.notification.NotificationService/ListNotifications" => {
285 #[allow(non_camel_case_types)]
286 struct ListNotificationsSvc<T: NotificationService>(pub Arc<T>);
287 impl<
288 T: NotificationService,
289 > tonic::server::UnaryService<super::ListNotificationsRequest>
290 for ListNotificationsSvc<T> {
291 type Response = super::ListNotificationsResponse;
292 type Future = BoxFuture<
293 tonic::Response<Self::Response>,
294 tonic::Status,
295 >;
296 fn call(
297 &mut self,
298 request: tonic::Request<super::ListNotificationsRequest>,
299 ) -> Self::Future {
300 let inner = Arc::clone(&self.0);
301 let fut = async move {
302 <T as NotificationService>::list_notifications(
303 &inner,
304 request,
305 )
306 .await
307 };
308 Box::pin(fut)
309 }
310 }
311 let accept_compression_encodings = self.accept_compression_encodings;
312 let send_compression_encodings = self.send_compression_encodings;
313 let max_decoding_message_size = self.max_decoding_message_size;
314 let max_encoding_message_size = self.max_encoding_message_size;
315 let inner = self.inner.clone();
316 let fut = async move {
317 let method = ListNotificationsSvc(inner);
318 let codec = tonic::codec::ProstCodec::default();
319 let mut grpc = tonic::server::Grpc::new(codec)
320 .apply_compression_config(
321 accept_compression_encodings,
322 send_compression_encodings,
323 )
324 .apply_max_message_size_config(
325 max_decoding_message_size,
326 max_encoding_message_size,
327 );
328 let res = grpc.unary(method, req).await;
329 Ok(res)
330 };
331 Box::pin(fut)
332 }
333 "/kdo.v1.notification.NotificationService/SubscribeNotifications" => {
334 #[allow(non_camel_case_types)]
335 struct SubscribeNotificationsSvc<T: NotificationService>(pub Arc<T>);
336 impl<
337 T: NotificationService,
338 > tonic::server::ServerStreamingService<
339 super::SubscribeNotificationsRequest,
340 > for SubscribeNotificationsSvc<T> {
341 type Response = super::Notification;
342 type ResponseStream = T::SubscribeNotificationsStream;
343 type Future = BoxFuture<
344 tonic::Response<Self::ResponseStream>,
345 tonic::Status,
346 >;
347 fn call(
348 &mut self,
349 request: tonic::Request<super::SubscribeNotificationsRequest>,
350 ) -> Self::Future {
351 let inner = Arc::clone(&self.0);
352 let fut = async move {
353 <T as NotificationService>::subscribe_notifications(
354 &inner,
355 request,
356 )
357 .await
358 };
359 Box::pin(fut)
360 }
361 }
362 let accept_compression_encodings = self.accept_compression_encodings;
363 let send_compression_encodings = self.send_compression_encodings;
364 let max_decoding_message_size = self.max_decoding_message_size;
365 let max_encoding_message_size = self.max_encoding_message_size;
366 let inner = self.inner.clone();
367 let fut = async move {
368 let method = SubscribeNotificationsSvc(inner);
369 let codec = tonic::codec::ProstCodec::default();
370 let mut grpc = tonic::server::Grpc::new(codec)
371 .apply_compression_config(
372 accept_compression_encodings,
373 send_compression_encodings,
374 )
375 .apply_max_message_size_config(
376 max_decoding_message_size,
377 max_encoding_message_size,
378 );
379 let res = grpc.server_streaming(method, req).await;
380 Ok(res)
381 };
382 Box::pin(fut)
383 }
384 "/kdo.v1.notification.NotificationService/AcknowledgeNotification" => {
385 #[allow(non_camel_case_types)]
386 struct AcknowledgeNotificationSvc<T: NotificationService>(
387 pub Arc<T>,
388 );
389 impl<
390 T: NotificationService,
391 > tonic::server::UnaryService<super::AcknowledgeNotificationRequest>
392 for AcknowledgeNotificationSvc<T> {
393 type Response = ();
394 type Future = BoxFuture<
395 tonic::Response<Self::Response>,
396 tonic::Status,
397 >;
398 fn call(
399 &mut self,
400 request: tonic::Request<
401 super::AcknowledgeNotificationRequest,
402 >,
403 ) -> Self::Future {
404 let inner = Arc::clone(&self.0);
405 let fut = async move {
406 <T as NotificationService>::acknowledge_notification(
407 &inner,
408 request,
409 )
410 .await
411 };
412 Box::pin(fut)
413 }
414 }
415 let accept_compression_encodings = self.accept_compression_encodings;
416 let send_compression_encodings = self.send_compression_encodings;
417 let max_decoding_message_size = self.max_decoding_message_size;
418 let max_encoding_message_size = self.max_encoding_message_size;
419 let inner = self.inner.clone();
420 let fut = async move {
421 let method = AcknowledgeNotificationSvc(inner);
422 let codec = tonic::codec::ProstCodec::default();
423 let mut grpc = tonic::server::Grpc::new(codec)
424 .apply_compression_config(
425 accept_compression_encodings,
426 send_compression_encodings,
427 )
428 .apply_max_message_size_config(
429 max_decoding_message_size,
430 max_encoding_message_size,
431 );
432 let res = grpc.unary(method, req).await;
433 Ok(res)
434 };
435 Box::pin(fut)
436 }
437 _ => {
438 Box::pin(async move {
439 Ok(
440 http::Response::builder()
441 .status(200)
442 .header("grpc-status", tonic::Code::Unimplemented as i32)
443 .header(
444 http::header::CONTENT_TYPE,
445 tonic::metadata::GRPC_CONTENT_TYPE,
446 )
447 .body(empty_body())
448 .unwrap(),
449 )
450 })
451 }
452 }
453 }
454 }
455 impl<T: NotificationService> Clone for NotificationServiceServer<T> {
456 fn clone(&self) -> Self {
457 let inner = self.inner.clone();
458 Self {
459 inner,
460 accept_compression_encodings: self.accept_compression_encodings,
461 send_compression_encodings: self.send_compression_encodings,
462 max_decoding_message_size: self.max_decoding_message_size,
463 max_encoding_message_size: self.max_encoding_message_size,
464 }
465 }
466 }
467 impl<T: NotificationService> tonic::server::NamedService
468 for NotificationServiceServer<T> {
469 const NAME: &'static str = "kdo.v1.notification.NotificationService";
470 }
471}