1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct ControlMessage {
4 #[prost(string, tag = "1")]
5 pub message_id: ::prost::alloc::string::String,
6 #[prost(oneof = "control_message::Payload", tags = "2, 3")]
7 pub payload: ::core::option::Option<control_message::Payload>,
8}
9pub mod control_message {
11 #[derive(Clone, PartialEq, ::prost::Oneof)]
12 pub enum Payload {
13 #[prost(message, tag = "2")]
14 ConfigCommand(super::ConfigurationCommand),
15 #[prost(message, tag = "3")]
16 Ack(super::Ack),
17 }
18}
19#[derive(Clone, PartialEq, ::prost::Message)]
20pub struct Connection {
21 #[prost(string, tag = "1")]
22 pub connection_id: ::prost::alloc::string::String,
23 #[prost(string, tag = "2")]
24 pub remote_address: ::prost::alloc::string::String,
25 #[prost(int32, tag = "3")]
26 pub remote_port: i32,
27}
28#[derive(Clone, PartialEq, ::prost::Message)]
29pub struct Route {
30 #[prost(string, tag = "1")]
31 pub company: ::prost::alloc::string::String,
32 #[prost(string, tag = "2")]
33 pub namespace: ::prost::alloc::string::String,
34 #[prost(string, tag = "3")]
35 pub agent_name: ::prost::alloc::string::String,
36 #[prost(message, optional, tag = "4")]
37 pub agent_id: ::core::option::Option<u64>,
38 #[prost(string, tag = "5")]
39 pub connection_id: ::prost::alloc::string::String,
40}
41#[derive(Clone, PartialEq, ::prost::Message)]
42pub struct ConfigurationCommand {
43 #[prost(message, repeated, tag = "1")]
44 pub connections_to_create: ::prost::alloc::vec::Vec<Connection>,
45 #[prost(message, repeated, tag = "2")]
46 pub routes_to_set: ::prost::alloc::vec::Vec<Route>,
47 #[prost(message, repeated, tag = "3")]
48 pub routes_to_delete: ::prost::alloc::vec::Vec<Route>,
49}
50#[derive(Clone, PartialEq, ::prost::Message)]
51pub struct Ack {
52 #[prost(string, tag = "1")]
53 pub original_message_id: ::prost::alloc::string::String,
54 #[prost(bool, tag = "2")]
55 pub success: bool,
56 #[prost(string, repeated, tag = "3")]
57 pub messages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
58}
59pub mod controller_service_client {
61 #![allow(
62 unused_variables,
63 dead_code,
64 missing_docs,
65 clippy::wildcard_imports,
66 clippy::let_unit_value,
67 )]
68 use tonic::codegen::*;
69 use tonic::codegen::http::Uri;
70 #[derive(Debug, Clone)]
71 pub struct ControllerServiceClient<T> {
72 inner: tonic::client::Grpc<T>,
73 }
74 impl ControllerServiceClient<tonic::transport::Channel> {
75 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
77 where
78 D: TryInto<tonic::transport::Endpoint>,
79 D::Error: Into<StdError>,
80 {
81 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
82 Ok(Self::new(conn))
83 }
84 }
85 impl<T> ControllerServiceClient<T>
86 where
87 T: tonic::client::GrpcService<tonic::body::Body>,
88 T::Error: Into<StdError>,
89 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
90 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
91 {
92 pub fn new(inner: T) -> Self {
93 let inner = tonic::client::Grpc::new(inner);
94 Self { inner }
95 }
96 pub fn with_origin(inner: T, origin: Uri) -> Self {
97 let inner = tonic::client::Grpc::with_origin(inner, origin);
98 Self { inner }
99 }
100 pub fn with_interceptor<F>(
101 inner: T,
102 interceptor: F,
103 ) -> ControllerServiceClient<InterceptedService<T, F>>
104 where
105 F: tonic::service::Interceptor,
106 T::ResponseBody: Default,
107 T: tonic::codegen::Service<
108 http::Request<tonic::body::Body>,
109 Response = http::Response<
110 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
111 >,
112 >,
113 <T as tonic::codegen::Service<
114 http::Request<tonic::body::Body>,
115 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
116 {
117 ControllerServiceClient::new(InterceptedService::new(inner, interceptor))
118 }
119 #[must_use]
124 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
125 self.inner = self.inner.send_compressed(encoding);
126 self
127 }
128 #[must_use]
130 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
131 self.inner = self.inner.accept_compressed(encoding);
132 self
133 }
134 #[must_use]
138 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
139 self.inner = self.inner.max_decoding_message_size(limit);
140 self
141 }
142 #[must_use]
146 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
147 self.inner = self.inner.max_encoding_message_size(limit);
148 self
149 }
150 pub async fn open_control_channel(
151 &mut self,
152 request: impl tonic::IntoStreamingRequest<Message = super::ControlMessage>,
153 ) -> std::result::Result<
154 tonic::Response<tonic::codec::Streaming<super::ControlMessage>>,
155 tonic::Status,
156 > {
157 self.inner
158 .ready()
159 .await
160 .map_err(|e| {
161 tonic::Status::unknown(
162 format!("Service was not ready: {}", e.into()),
163 )
164 })?;
165 let codec = tonic::codec::ProstCodec::default();
166 let path = http::uri::PathAndQuery::from_static(
167 "/controller.proto.v1.ControllerService/OpenControlChannel",
168 );
169 let mut req = request.into_streaming_request();
170 req.extensions_mut()
171 .insert(
172 GrpcMethod::new(
173 "controller.proto.v1.ControllerService",
174 "OpenControlChannel",
175 ),
176 );
177 self.inner.streaming(req, path, codec).await
178 }
179 }
180}
181pub mod controller_service_server {
183 #![allow(
184 unused_variables,
185 dead_code,
186 missing_docs,
187 clippy::wildcard_imports,
188 clippy::let_unit_value,
189 )]
190 use tonic::codegen::*;
191 #[async_trait]
193 pub trait ControllerService: std::marker::Send + std::marker::Sync + 'static {
194 type OpenControlChannelStream: tonic::codegen::tokio_stream::Stream<
196 Item = std::result::Result<super::ControlMessage, tonic::Status>,
197 >
198 + std::marker::Send
199 + 'static;
200 async fn open_control_channel(
201 &self,
202 request: tonic::Request<tonic::Streaming<super::ControlMessage>>,
203 ) -> std::result::Result<
204 tonic::Response<Self::OpenControlChannelStream>,
205 tonic::Status,
206 >;
207 }
208 #[derive(Debug)]
209 pub struct ControllerServiceServer<T> {
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> ControllerServiceServer<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 ControllerServiceServer<T>
268 where
269 T: ControllerService,
270 B: Body + std::marker::Send + 'static,
271 B::Error: Into<StdError> + std::marker::Send + 'static,
272 {
273 type Response = http::Response<tonic::body::Body>;
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 "/controller.proto.v1.ControllerService/OpenControlChannel" => {
285 #[allow(non_camel_case_types)]
286 struct OpenControlChannelSvc<T: ControllerService>(pub Arc<T>);
287 impl<
288 T: ControllerService,
289 > tonic::server::StreamingService<super::ControlMessage>
290 for OpenControlChannelSvc<T> {
291 type Response = super::ControlMessage;
292 type ResponseStream = T::OpenControlChannelStream;
293 type Future = BoxFuture<
294 tonic::Response<Self::ResponseStream>,
295 tonic::Status,
296 >;
297 fn call(
298 &mut self,
299 request: tonic::Request<
300 tonic::Streaming<super::ControlMessage>,
301 >,
302 ) -> Self::Future {
303 let inner = Arc::clone(&self.0);
304 let fut = async move {
305 <T as ControllerService>::open_control_channel(
306 &inner,
307 request,
308 )
309 .await
310 };
311 Box::pin(fut)
312 }
313 }
314 let accept_compression_encodings = self.accept_compression_encodings;
315 let send_compression_encodings = self.send_compression_encodings;
316 let max_decoding_message_size = self.max_decoding_message_size;
317 let max_encoding_message_size = self.max_encoding_message_size;
318 let inner = self.inner.clone();
319 let fut = async move {
320 let method = OpenControlChannelSvc(inner);
321 let codec = tonic::codec::ProstCodec::default();
322 let mut grpc = tonic::server::Grpc::new(codec)
323 .apply_compression_config(
324 accept_compression_encodings,
325 send_compression_encodings,
326 )
327 .apply_max_message_size_config(
328 max_decoding_message_size,
329 max_encoding_message_size,
330 );
331 let res = grpc.streaming(method, req).await;
332 Ok(res)
333 };
334 Box::pin(fut)
335 }
336 _ => {
337 Box::pin(async move {
338 let mut response = http::Response::new(
339 tonic::body::Body::default(),
340 );
341 let headers = response.headers_mut();
342 headers
343 .insert(
344 tonic::Status::GRPC_STATUS,
345 (tonic::Code::Unimplemented as i32).into(),
346 );
347 headers
348 .insert(
349 http::header::CONTENT_TYPE,
350 tonic::metadata::GRPC_CONTENT_TYPE,
351 );
352 Ok(response)
353 })
354 }
355 }
356 }
357 }
358 impl<T> Clone for ControllerServiceServer<T> {
359 fn clone(&self) -> Self {
360 let inner = self.inner.clone();
361 Self {
362 inner,
363 accept_compression_encodings: self.accept_compression_encodings,
364 send_compression_encodings: self.send_compression_encodings,
365 max_decoding_message_size: self.max_decoding_message_size,
366 max_encoding_message_size: self.max_encoding_message_size,
367 }
368 }
369 }
370 pub const SERVICE_NAME: &str = "controller.proto.v1.ControllerService";
372 impl<T> tonic::server::NamedService for ControllerServiceServer<T> {
373 const NAME: &'static str = SERVICE_NAME;
374 }
375}