agp_datapath/pubsub/gen/
pubsub.proto.v1.rs

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