Skip to main content

slim_controller/api/gen/
controller.proto.v1.rs

1// This file is @generated by prost-build.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct ControlMessage {
4    #[prost(string, tag = "1")]
5    pub message_id: ::prost::alloc::string::String,
6    #[prost(
7        oneof = "control_message::Payload",
8        tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20"
9    )]
10    pub payload: ::core::option::Option<control_message::Payload>,
11}
12/// Nested message and enum types in `ControlMessage`.
13pub mod control_message {
14    #[derive(Clone, PartialEq, ::prost::Oneof)]
15    pub enum Payload {
16        #[prost(message, tag = "2")]
17        ConfigCommand(super::ConfigurationCommand),
18        #[prost(message, tag = "3")]
19        Ack(super::Ack),
20        #[prost(message, tag = "4")]
21        RouteListRequest(super::RouteListRequest),
22        #[prost(message, tag = "5")]
23        RouteListResponse(super::RouteListResponse),
24        #[prost(message, tag = "6")]
25        ConnectionListRequest(super::ConnectionListRequest),
26        #[prost(message, tag = "7")]
27        ConnectionListResponse(super::ConnectionListResponse),
28        #[prost(message, tag = "8")]
29        RegisterNodeRequest(super::RegisterNodeRequest),
30        #[prost(message, tag = "9")]
31        RegisterNodeResponse(super::RegisterNodeResponse),
32        #[prost(message, tag = "10")]
33        DeregisterNodeRequest(super::DeregisterNodeRequest),
34        #[prost(message, tag = "11")]
35        DeregisterNodeResponse(super::DeregisterNodeResponse),
36        #[prost(message, tag = "20")]
37        ConfigCommandAck(super::ConfigurationCommandAck),
38    }
39}
40#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
41pub struct Connection {
42    #[prost(string, tag = "1")]
43    pub link_id: ::prost::alloc::string::String,
44    #[prost(string, tag = "2")]
45    pub config_data: ::prost::alloc::string::String,
46}
47#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
48pub struct ConnectionAck {
49    #[prost(string, tag = "1")]
50    pub link_id: ::prost::alloc::string::String,
51    #[prost(bool, tag = "2")]
52    pub success: bool,
53    #[prost(string, tag = "3")]
54    pub error_msg: ::prost::alloc::string::String,
55}
56#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
57pub struct Route {
58    #[prost(message, optional, tag = "1")]
59    pub name: ::core::option::Option<::slim_datapath::api::proto::dataplane::v1::Name>,
60    #[prost(string, optional, tag = "2")]
61    pub link_id: ::core::option::Option<::prost::alloc::string::String>,
62    #[prost(enumeration = "ConnectionDirection", optional, tag = "3")]
63    pub direction: ::core::option::Option<i32>,
64}
65#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
66pub struct RouteAck {
67    #[prost(message, optional, tag = "1")]
68    pub route: ::core::option::Option<Route>,
69    #[prost(bool, tag = "2")]
70    pub success: bool,
71    #[prost(string, tag = "3")]
72    pub error_msg: ::prost::alloc::string::String,
73}
74#[derive(Clone, PartialEq, ::prost::Message)]
75pub struct ConfigurationCommand {
76    #[prost(message, repeated, tag = "1")]
77    pub connections_to_create: ::prost::alloc::vec::Vec<Connection>,
78    #[prost(message, repeated, tag = "2")]
79    pub routes_to_set: ::prost::alloc::vec::Vec<Route>,
80    #[prost(message, repeated, tag = "3")]
81    pub routes_to_delete: ::prost::alloc::vec::Vec<Route>,
82    #[prost(string, repeated, tag = "4")]
83    pub connections_to_delete: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
84    #[prost(bool, tag = "5")]
85    pub reconcile: bool,
86}
87#[derive(Clone, PartialEq, ::prost::Message)]
88pub struct ConfigurationCommandAck {
89    #[prost(string, tag = "1")]
90    pub original_message_id: ::prost::alloc::string::String,
91    #[prost(message, repeated, tag = "2")]
92    pub connections_status: ::prost::alloc::vec::Vec<ConnectionAck>,
93    #[prost(message, repeated, tag = "3")]
94    pub routes_status: ::prost::alloc::vec::Vec<RouteAck>,
95}
96#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
97pub struct Ack {
98    #[prost(string, tag = "1")]
99    pub original_message_id: ::prost::alloc::string::String,
100    #[prost(bool, tag = "2")]
101    pub success: bool,
102    #[prost(string, repeated, tag = "3")]
103    pub messages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
104}
105#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
106pub struct RouteListRequest {}
107#[derive(Clone, PartialEq, ::prost::Message)]
108pub struct RouteListResponse {
109    #[prost(string, tag = "1")]
110    pub original_message_id: ::prost::alloc::string::String,
111    #[prost(message, repeated, tag = "2")]
112    pub entries: ::prost::alloc::vec::Vec<RouteEntry>,
113    #[prost(bool, tag = "3")]
114    pub done: bool,
115}
116#[derive(Clone, PartialEq, ::prost::Message)]
117pub struct RouteEntry {
118    #[prost(message, optional, tag = "1")]
119    pub name: ::core::option::Option<::slim_datapath::api::proto::dataplane::v1::Name>,
120    #[prost(message, repeated, tag = "2")]
121    pub connections: ::prost::alloc::vec::Vec<ConnectionEntry>,
122}
123#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
124pub struct ConnectionEntry {
125    #[prost(uint64, tag = "1")]
126    pub id: u64,
127    #[prost(enumeration = "ConnectionType", tag = "2")]
128    pub connection_type: i32,
129    #[prost(string, tag = "3")]
130    pub config_data: ::prost::alloc::string::String,
131    #[prost(string, optional, tag = "4")]
132    pub link_id: ::core::option::Option<::prost::alloc::string::String>,
133    #[prost(enumeration = "ConnectionDirection", tag = "5")]
134    pub direction: i32,
135    /// Remote peer's node identifier (set after link negotiation).
136    #[prost(string, optional, tag = "6")]
137    pub peer_node_id: ::core::option::Option<::prost::alloc::string::String>,
138}
139#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
140pub struct ConnectionListRequest {}
141#[derive(Clone, PartialEq, ::prost::Message)]
142pub struct ConnectionListResponse {
143    #[prost(string, tag = "1")]
144    pub original_message_id: ::prost::alloc::string::String,
145    #[prost(message, repeated, tag = "2")]
146    pub entries: ::prost::alloc::vec::Vec<ConnectionEntry>,
147    #[prost(bool, tag = "3")]
148    pub done: bool,
149}
150#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
151pub struct Node {
152    #[prost(string, tag = "1")]
153    pub id: ::prost::alloc::string::String,
154}
155#[derive(Clone, PartialEq, ::prost::Message)]
156pub struct ConnectionDetails {
157    #[prost(string, tag = "1")]
158    pub endpoint: ::prost::alloc::string::String,
159    #[prost(string, optional, tag = "2")]
160    pub external_endpoint: ::core::option::Option<::prost::alloc::string::String>,
161    #[prost(message, optional, tag = "3")]
162    pub spire_mtls: ::core::option::Option<connection_details::SpireMtls>,
163    #[prost(message, optional, tag = "4")]
164    pub metadata: ::core::option::Option<::prost_types::Struct>,
165}
166/// Nested message and enum types in `ConnectionDetails`.
167pub mod connection_details {
168    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
169    pub struct SpireMtls {
170        #[prost(string, tag = "1")]
171        pub socket_path: ::prost::alloc::string::String,
172        #[prost(string, optional, tag = "2")]
173        pub trust_domain: ::core::option::Option<::prost::alloc::string::String>,
174    }
175}
176#[derive(Clone, PartialEq, ::prost::Message)]
177pub struct RegisterNodeRequest {
178    #[prost(string, tag = "1")]
179    pub node_id: ::prost::alloc::string::String,
180    #[prost(message, repeated, tag = "2")]
181    pub connection_details: ::prost::alloc::vec::Vec<ConnectionDetails>,
182    #[prost(string, optional, tag = "3")]
183    pub group_name: ::core::option::Option<::prost::alloc::string::String>,
184    /// Active connections on the data plane at the time of registration.
185    /// Allows the control plane to reconcile link state without an extra round-trip.
186    #[prost(message, repeated, tag = "4")]
187    pub connections: ::prost::alloc::vec::Vec<ConnectionEntry>,
188    /// Active routes on the data plane at the time of registration.
189    #[prost(message, repeated, tag = "5")]
190    pub routes: ::prost::alloc::vec::Vec<Route>,
191}
192#[derive(Clone, PartialEq, ::prost::Message)]
193pub struct RegisterNodeResponse {
194    #[prost(string, tag = "1")]
195    pub original_message_id: ::prost::alloc::string::String,
196    #[prost(bool, tag = "2")]
197    pub success: bool,
198    /// Current desired state for the node — connections to maintain and routes to set.
199    #[prost(message, repeated, tag = "3")]
200    pub connections: ::prost::alloc::vec::Vec<Connection>,
201    #[prost(message, repeated, tag = "4")]
202    pub routes: ::prost::alloc::vec::Vec<Route>,
203}
204#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
205pub struct DeregisterNodeRequest {
206    #[prost(message, optional, tag = "1")]
207    pub node: ::core::option::Option<Node>,
208}
209#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
210pub struct DeregisterNodeResponse {
211    #[prost(string, tag = "1")]
212    pub original_message_id: ::prost::alloc::string::String,
213    #[prost(bool, tag = "2")]
214    pub success: bool,
215}
216#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
217#[repr(i32)]
218pub enum ConnectionType {
219    Local = 0,
220    Remote = 1,
221    Peer = 2,
222}
223impl ConnectionType {
224    /// String value of the enum field names used in the ProtoBuf definition.
225    ///
226    /// The values are not transformed in any way and thus are considered stable
227    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
228    pub fn as_str_name(&self) -> &'static str {
229        match self {
230            Self::Local => "CONNECTION_TYPE_LOCAL",
231            Self::Remote => "CONNECTION_TYPE_REMOTE",
232            Self::Peer => "CONNECTION_TYPE_PEER",
233        }
234    }
235    /// Creates an enum from field names used in the ProtoBuf definition.
236    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
237        match value {
238            "CONNECTION_TYPE_LOCAL" => Some(Self::Local),
239            "CONNECTION_TYPE_REMOTE" => Some(Self::Remote),
240            "CONNECTION_TYPE_PEER" => Some(Self::Peer),
241            _ => None,
242        }
243    }
244}
245#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
246#[repr(i32)]
247pub enum ConnectionDirection {
248    Outgoing = 0,
249    Incoming = 1,
250}
251impl ConnectionDirection {
252    /// String value of the enum field names used in the ProtoBuf definition.
253    ///
254    /// The values are not transformed in any way and thus are considered stable
255    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
256    pub fn as_str_name(&self) -> &'static str {
257        match self {
258            Self::Outgoing => "CONNECTION_DIRECTION_OUTGOING",
259            Self::Incoming => "CONNECTION_DIRECTION_INCOMING",
260        }
261    }
262    /// Creates an enum from field names used in the ProtoBuf definition.
263    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
264        match value {
265            "CONNECTION_DIRECTION_OUTGOING" => Some(Self::Outgoing),
266            "CONNECTION_DIRECTION_INCOMING" => Some(Self::Incoming),
267            _ => None,
268        }
269    }
270}
271/// Generated client implementations.
272pub mod controller_service_client {
273    #![allow(
274        unused_variables,
275        dead_code,
276        missing_docs,
277        clippy::wildcard_imports,
278        clippy::let_unit_value,
279    )]
280    use tonic::codegen::*;
281    use tonic::codegen::http::Uri;
282    #[derive(Debug, Clone)]
283    pub struct ControllerServiceClient<T> {
284        inner: tonic::client::Grpc<T>,
285    }
286    impl ControllerServiceClient<tonic::transport::Channel> {
287        /// Attempt to create a new client by connecting to a given endpoint.
288        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
289        where
290            D: TryInto<tonic::transport::Endpoint>,
291            D::Error: Into<StdError>,
292        {
293            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
294            Ok(Self::new(conn))
295        }
296    }
297    impl<T> ControllerServiceClient<T>
298    where
299        T: tonic::client::GrpcService<tonic::body::Body>,
300        T::Error: Into<StdError>,
301        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
302        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
303    {
304        pub fn new(inner: T) -> Self {
305            let inner = tonic::client::Grpc::new(inner);
306            Self { inner }
307        }
308        pub fn with_origin(inner: T, origin: Uri) -> Self {
309            let inner = tonic::client::Grpc::with_origin(inner, origin);
310            Self { inner }
311        }
312        pub fn with_interceptor<F>(
313            inner: T,
314            interceptor: F,
315        ) -> ControllerServiceClient<InterceptedService<T, F>>
316        where
317            F: tonic::service::Interceptor,
318            T::ResponseBody: Default,
319            T: tonic::codegen::Service<
320                http::Request<tonic::body::Body>,
321                Response = http::Response<
322                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
323                >,
324            >,
325            <T as tonic::codegen::Service<
326                http::Request<tonic::body::Body>,
327            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
328        {
329            ControllerServiceClient::new(InterceptedService::new(inner, interceptor))
330        }
331        /// Compress requests with the given encoding.
332        ///
333        /// This requires the server to support it otherwise it might respond with an
334        /// error.
335        #[must_use]
336        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
337            self.inner = self.inner.send_compressed(encoding);
338            self
339        }
340        /// Enable decompressing responses.
341        #[must_use]
342        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
343            self.inner = self.inner.accept_compressed(encoding);
344            self
345        }
346        /// Limits the maximum size of a decoded message.
347        ///
348        /// Default: `4MB`
349        #[must_use]
350        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
351            self.inner = self.inner.max_decoding_message_size(limit);
352            self
353        }
354        /// Limits the maximum size of an encoded message.
355        ///
356        /// Default: `usize::MAX`
357        #[must_use]
358        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
359            self.inner = self.inner.max_encoding_message_size(limit);
360            self
361        }
362        pub async fn open_control_channel(
363            &mut self,
364            request: impl tonic::IntoStreamingRequest<Message = super::ControlMessage>,
365        ) -> std::result::Result<
366            tonic::Response<tonic::codec::Streaming<super::ControlMessage>>,
367            tonic::Status,
368        > {
369            self.inner
370                .ready()
371                .await
372                .map_err(|e| {
373                    tonic::Status::unknown(
374                        format!("Service was not ready: {}", e.into()),
375                    )
376                })?;
377            let codec = tonic_prost::ProstCodec::default();
378            let path = http::uri::PathAndQuery::from_static(
379                "/controller.proto.v1.ControllerService/OpenControlChannel",
380            );
381            let mut req = request.into_streaming_request();
382            req.extensions_mut()
383                .insert(
384                    GrpcMethod::new(
385                        "controller.proto.v1.ControllerService",
386                        "OpenControlChannel",
387                    ),
388                );
389            self.inner.streaming(req, path, codec).await
390        }
391    }
392}
393/// Generated server implementations.
394pub mod controller_service_server {
395    #![allow(
396        unused_variables,
397        dead_code,
398        missing_docs,
399        clippy::wildcard_imports,
400        clippy::let_unit_value,
401    )]
402    use tonic::codegen::*;
403    /// Generated trait containing gRPC methods that should be implemented for use with ControllerServiceServer.
404    #[async_trait]
405    pub trait ControllerService: std::marker::Send + std::marker::Sync + 'static {
406        /// Server streaming response type for the OpenControlChannel method.
407        type OpenControlChannelStream: tonic::codegen::tokio_stream::Stream<
408                Item = std::result::Result<super::ControlMessage, tonic::Status>,
409            >
410            + std::marker::Send
411            + 'static;
412        async fn open_control_channel(
413            &self,
414            request: tonic::Request<tonic::Streaming<super::ControlMessage>>,
415        ) -> std::result::Result<
416            tonic::Response<Self::OpenControlChannelStream>,
417            tonic::Status,
418        >;
419    }
420    #[derive(Debug)]
421    pub struct ControllerServiceServer<T> {
422        inner: Arc<T>,
423        accept_compression_encodings: EnabledCompressionEncodings,
424        send_compression_encodings: EnabledCompressionEncodings,
425        max_decoding_message_size: Option<usize>,
426        max_encoding_message_size: Option<usize>,
427    }
428    impl<T> ControllerServiceServer<T> {
429        pub fn new(inner: T) -> Self {
430            Self::from_arc(Arc::new(inner))
431        }
432        pub fn from_arc(inner: Arc<T>) -> Self {
433            Self {
434                inner,
435                accept_compression_encodings: Default::default(),
436                send_compression_encodings: Default::default(),
437                max_decoding_message_size: None,
438                max_encoding_message_size: None,
439            }
440        }
441        pub fn with_interceptor<F>(
442            inner: T,
443            interceptor: F,
444        ) -> InterceptedService<Self, F>
445        where
446            F: tonic::service::Interceptor,
447        {
448            InterceptedService::new(Self::new(inner), interceptor)
449        }
450        /// Enable decompressing requests with the given encoding.
451        #[must_use]
452        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
453            self.accept_compression_encodings.enable(encoding);
454            self
455        }
456        /// Compress responses with the given encoding, if the client supports it.
457        #[must_use]
458        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
459            self.send_compression_encodings.enable(encoding);
460            self
461        }
462        /// Limits the maximum size of a decoded message.
463        ///
464        /// Default: `4MB`
465        #[must_use]
466        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
467            self.max_decoding_message_size = Some(limit);
468            self
469        }
470        /// Limits the maximum size of an encoded message.
471        ///
472        /// Default: `usize::MAX`
473        #[must_use]
474        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
475            self.max_encoding_message_size = Some(limit);
476            self
477        }
478    }
479    impl<T, B> tonic::codegen::Service<http::Request<B>> for ControllerServiceServer<T>
480    where
481        T: ControllerService,
482        B: Body + std::marker::Send + 'static,
483        B::Error: Into<StdError> + std::marker::Send + 'static,
484    {
485        type Response = http::Response<tonic::body::Body>;
486        type Error = std::convert::Infallible;
487        type Future = BoxFuture<Self::Response, Self::Error>;
488        fn poll_ready(
489            &mut self,
490            _cx: &mut Context<'_>,
491        ) -> Poll<std::result::Result<(), Self::Error>> {
492            Poll::Ready(Ok(()))
493        }
494        fn call(&mut self, req: http::Request<B>) -> Self::Future {
495            match req.uri().path() {
496                "/controller.proto.v1.ControllerService/OpenControlChannel" => {
497                    #[allow(non_camel_case_types)]
498                    struct OpenControlChannelSvc<T: ControllerService>(pub Arc<T>);
499                    impl<
500                        T: ControllerService,
501                    > tonic::server::StreamingService<super::ControlMessage>
502                    for OpenControlChannelSvc<T> {
503                        type Response = super::ControlMessage;
504                        type ResponseStream = T::OpenControlChannelStream;
505                        type Future = BoxFuture<
506                            tonic::Response<Self::ResponseStream>,
507                            tonic::Status,
508                        >;
509                        fn call(
510                            &mut self,
511                            request: tonic::Request<
512                                tonic::Streaming<super::ControlMessage>,
513                            >,
514                        ) -> Self::Future {
515                            let inner = Arc::clone(&self.0);
516                            let fut = async move {
517                                <T as ControllerService>::open_control_channel(
518                                        &inner,
519                                        request,
520                                    )
521                                    .await
522                            };
523                            Box::pin(fut)
524                        }
525                    }
526                    let accept_compression_encodings = self.accept_compression_encodings;
527                    let send_compression_encodings = self.send_compression_encodings;
528                    let max_decoding_message_size = self.max_decoding_message_size;
529                    let max_encoding_message_size = self.max_encoding_message_size;
530                    let inner = self.inner.clone();
531                    let fut = async move {
532                        let method = OpenControlChannelSvc(inner);
533                        let codec = tonic_prost::ProstCodec::default();
534                        let mut grpc = tonic::server::Grpc::new(codec)
535                            .apply_compression_config(
536                                accept_compression_encodings,
537                                send_compression_encodings,
538                            )
539                            .apply_max_message_size_config(
540                                max_decoding_message_size,
541                                max_encoding_message_size,
542                            );
543                        let res = grpc.streaming(method, req).await;
544                        Ok(res)
545                    };
546                    Box::pin(fut)
547                }
548                _ => {
549                    Box::pin(async move {
550                        let mut response = http::Response::new(
551                            tonic::body::Body::default(),
552                        );
553                        let headers = response.headers_mut();
554                        headers
555                            .insert(
556                                tonic::Status::GRPC_STATUS,
557                                (tonic::Code::Unimplemented as i32).into(),
558                            );
559                        headers
560                            .insert(
561                                http::header::CONTENT_TYPE,
562                                tonic::metadata::GRPC_CONTENT_TYPE,
563                            );
564                        Ok(response)
565                    })
566                }
567            }
568        }
569    }
570    impl<T> Clone for ControllerServiceServer<T> {
571        fn clone(&self) -> Self {
572            let inner = self.inner.clone();
573            Self {
574                inner,
575                accept_compression_encodings: self.accept_compression_encodings,
576                send_compression_encodings: self.send_compression_encodings,
577                max_decoding_message_size: self.max_decoding_message_size,
578                max_encoding_message_size: self.max_encoding_message_size,
579            }
580        }
581    }
582    /// Generated gRPC service name
583    pub const SERVICE_NAME: &str = "controller.proto.v1.ControllerService";
584    impl<T> tonic::server::NamedService for ControllerServiceServer<T> {
585        const NAME: &'static str = SERVICE_NAME;
586    }
587}