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