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, 4, 5, 6, 7")]
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 #[prost(message, tag = "4")]
18 SubscriptionListRequest(super::SubscriptionListRequest),
19 #[prost(message, tag = "5")]
20 SubscriptionListResponse(super::SubscriptionListResponse),
21 #[prost(message, tag = "6")]
22 ConnectionListRequest(super::ConnectionListRequest),
23 #[prost(message, tag = "7")]
24 ConnectionListResponse(super::ConnectionListResponse),
25 }
26}
27#[derive(Clone, PartialEq, ::prost::Message)]
28pub struct Connection {
29 #[prost(string, tag = "1")]
30 pub connection_id: ::prost::alloc::string::String,
31 #[prost(string, tag = "2")]
32 pub remote_address: ::prost::alloc::string::String,
33 #[prost(int32, tag = "3")]
34 pub remote_port: i32,
35}
36#[derive(Clone, PartialEq, ::prost::Message)]
37pub struct Subscription {
38 #[prost(string, tag = "1")]
39 pub organization: ::prost::alloc::string::String,
40 #[prost(string, tag = "2")]
41 pub namespace: ::prost::alloc::string::String,
42 #[prost(string, tag = "3")]
43 pub agent_type: ::prost::alloc::string::String,
44 #[prost(message, optional, tag = "4")]
45 pub agent_id: ::core::option::Option<u64>,
46 #[prost(string, tag = "5")]
47 pub connection_id: ::prost::alloc::string::String,
48}
49#[derive(Clone, PartialEq, ::prost::Message)]
50pub struct ConfigurationCommand {
51 #[prost(message, repeated, tag = "1")]
52 pub connections_to_create: ::prost::alloc::vec::Vec<Connection>,
53 #[prost(message, repeated, tag = "2")]
54 pub subscriptions_to_set: ::prost::alloc::vec::Vec<Subscription>,
55 #[prost(message, repeated, tag = "3")]
56 pub subscriptions_to_delete: ::prost::alloc::vec::Vec<Subscription>,
57}
58#[derive(Clone, PartialEq, ::prost::Message)]
59pub struct Ack {
60 #[prost(string, tag = "1")]
61 pub original_message_id: ::prost::alloc::string::String,
62 #[prost(bool, tag = "2")]
63 pub success: bool,
64 #[prost(string, repeated, tag = "3")]
65 pub messages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
66}
67#[derive(Clone, Copy, PartialEq, ::prost::Message)]
68pub struct SubscriptionListRequest {}
69#[derive(Clone, PartialEq, ::prost::Message)]
70pub struct SubscriptionListResponse {
71 #[prost(message, repeated, tag = "1")]
72 pub entries: ::prost::alloc::vec::Vec<SubscriptionEntry>,
73}
74#[derive(Clone, PartialEq, ::prost::Message)]
75pub struct SubscriptionEntry {
76 #[prost(string, tag = "1")]
77 pub organization: ::prost::alloc::string::String,
78 #[prost(string, tag = "2")]
79 pub namespace: ::prost::alloc::string::String,
80 #[prost(string, tag = "3")]
81 pub agent_type: ::prost::alloc::string::String,
82 #[prost(message, optional, tag = "4")]
83 pub agent_id: ::core::option::Option<u64>,
84 #[prost(message, repeated, tag = "5")]
85 pub local_connections: ::prost::alloc::vec::Vec<ConnectionEntry>,
86 #[prost(message, repeated, tag = "6")]
87 pub remote_connections: ::prost::alloc::vec::Vec<ConnectionEntry>,
88}
89#[derive(Clone, PartialEq, ::prost::Message)]
90pub struct ConnectionEntry {
91 #[prost(uint64, tag = "1")]
92 pub id: u64,
93 #[prost(enumeration = "ConnectionType", tag = "2")]
94 pub connection_type: i32,
95 #[prost(string, tag = "3")]
96 pub ip: ::prost::alloc::string::String,
97 #[prost(uint32, tag = "4")]
98 pub port: u32,
99}
100#[derive(Clone, Copy, PartialEq, ::prost::Message)]
101pub struct ConnectionListRequest {}
102#[derive(Clone, PartialEq, ::prost::Message)]
103pub struct ConnectionListResponse {
104 #[prost(message, repeated, tag = "1")]
105 pub entries: ::prost::alloc::vec::Vec<ConnectionEntry>,
106}
107#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
108#[repr(i32)]
109pub enum ConnectionType {
110 Local = 0,
111 Remote = 1,
112}
113impl ConnectionType {
114 pub fn as_str_name(&self) -> &'static str {
119 match self {
120 Self::Local => "CONNECTION_TYPE_LOCAL",
121 Self::Remote => "CONNECTION_TYPE_REMOTE",
122 }
123 }
124 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
126 match value {
127 "CONNECTION_TYPE_LOCAL" => Some(Self::Local),
128 "CONNECTION_TYPE_REMOTE" => Some(Self::Remote),
129 _ => None,
130 }
131 }
132}
133pub mod controller_service_client {
135 #![allow(
136 unused_variables,
137 dead_code,
138 missing_docs,
139 clippy::wildcard_imports,
140 clippy::let_unit_value,
141 )]
142 use tonic::codegen::*;
143 use tonic::codegen::http::Uri;
144 #[derive(Debug, Clone)]
145 pub struct ControllerServiceClient<T> {
146 inner: tonic::client::Grpc<T>,
147 }
148 impl ControllerServiceClient<tonic::transport::Channel> {
149 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
151 where
152 D: TryInto<tonic::transport::Endpoint>,
153 D::Error: Into<StdError>,
154 {
155 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
156 Ok(Self::new(conn))
157 }
158 }
159 impl<T> ControllerServiceClient<T>
160 where
161 T: tonic::client::GrpcService<tonic::body::Body>,
162 T::Error: Into<StdError>,
163 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
164 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
165 {
166 pub fn new(inner: T) -> Self {
167 let inner = tonic::client::Grpc::new(inner);
168 Self { inner }
169 }
170 pub fn with_origin(inner: T, origin: Uri) -> Self {
171 let inner = tonic::client::Grpc::with_origin(inner, origin);
172 Self { inner }
173 }
174 pub fn with_interceptor<F>(
175 inner: T,
176 interceptor: F,
177 ) -> ControllerServiceClient<InterceptedService<T, F>>
178 where
179 F: tonic::service::Interceptor,
180 T::ResponseBody: Default,
181 T: tonic::codegen::Service<
182 http::Request<tonic::body::Body>,
183 Response = http::Response<
184 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
185 >,
186 >,
187 <T as tonic::codegen::Service<
188 http::Request<tonic::body::Body>,
189 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
190 {
191 ControllerServiceClient::new(InterceptedService::new(inner, interceptor))
192 }
193 #[must_use]
198 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
199 self.inner = self.inner.send_compressed(encoding);
200 self
201 }
202 #[must_use]
204 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
205 self.inner = self.inner.accept_compressed(encoding);
206 self
207 }
208 #[must_use]
212 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
213 self.inner = self.inner.max_decoding_message_size(limit);
214 self
215 }
216 #[must_use]
220 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
221 self.inner = self.inner.max_encoding_message_size(limit);
222 self
223 }
224 pub async fn open_control_channel(
225 &mut self,
226 request: impl tonic::IntoStreamingRequest<Message = super::ControlMessage>,
227 ) -> std::result::Result<
228 tonic::Response<tonic::codec::Streaming<super::ControlMessage>>,
229 tonic::Status,
230 > {
231 self.inner
232 .ready()
233 .await
234 .map_err(|e| {
235 tonic::Status::unknown(
236 format!("Service was not ready: {}", e.into()),
237 )
238 })?;
239 let codec = tonic::codec::ProstCodec::default();
240 let path = http::uri::PathAndQuery::from_static(
241 "/controller.proto.v1.ControllerService/OpenControlChannel",
242 );
243 let mut req = request.into_streaming_request();
244 req.extensions_mut()
245 .insert(
246 GrpcMethod::new(
247 "controller.proto.v1.ControllerService",
248 "OpenControlChannel",
249 ),
250 );
251 self.inner.streaming(req, path, codec).await
252 }
253 }
254}
255pub mod controller_service_server {
257 #![allow(
258 unused_variables,
259 dead_code,
260 missing_docs,
261 clippy::wildcard_imports,
262 clippy::let_unit_value,
263 )]
264 use tonic::codegen::*;
265 #[async_trait]
267 pub trait ControllerService: std::marker::Send + std::marker::Sync + 'static {
268 type OpenControlChannelStream: tonic::codegen::tokio_stream::Stream<
270 Item = std::result::Result<super::ControlMessage, tonic::Status>,
271 >
272 + std::marker::Send
273 + 'static;
274 async fn open_control_channel(
275 &self,
276 request: tonic::Request<tonic::Streaming<super::ControlMessage>>,
277 ) -> std::result::Result<
278 tonic::Response<Self::OpenControlChannelStream>,
279 tonic::Status,
280 >;
281 }
282 #[derive(Debug)]
283 pub struct ControllerServiceServer<T> {
284 inner: Arc<T>,
285 accept_compression_encodings: EnabledCompressionEncodings,
286 send_compression_encodings: EnabledCompressionEncodings,
287 max_decoding_message_size: Option<usize>,
288 max_encoding_message_size: Option<usize>,
289 }
290 impl<T> ControllerServiceServer<T> {
291 pub fn new(inner: T) -> Self {
292 Self::from_arc(Arc::new(inner))
293 }
294 pub fn from_arc(inner: Arc<T>) -> Self {
295 Self {
296 inner,
297 accept_compression_encodings: Default::default(),
298 send_compression_encodings: Default::default(),
299 max_decoding_message_size: None,
300 max_encoding_message_size: None,
301 }
302 }
303 pub fn with_interceptor<F>(
304 inner: T,
305 interceptor: F,
306 ) -> InterceptedService<Self, F>
307 where
308 F: tonic::service::Interceptor,
309 {
310 InterceptedService::new(Self::new(inner), interceptor)
311 }
312 #[must_use]
314 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
315 self.accept_compression_encodings.enable(encoding);
316 self
317 }
318 #[must_use]
320 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
321 self.send_compression_encodings.enable(encoding);
322 self
323 }
324 #[must_use]
328 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
329 self.max_decoding_message_size = Some(limit);
330 self
331 }
332 #[must_use]
336 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
337 self.max_encoding_message_size = Some(limit);
338 self
339 }
340 }
341 impl<T, B> tonic::codegen::Service<http::Request<B>> for ControllerServiceServer<T>
342 where
343 T: ControllerService,
344 B: Body + std::marker::Send + 'static,
345 B::Error: Into<StdError> + std::marker::Send + 'static,
346 {
347 type Response = http::Response<tonic::body::Body>;
348 type Error = std::convert::Infallible;
349 type Future = BoxFuture<Self::Response, Self::Error>;
350 fn poll_ready(
351 &mut self,
352 _cx: &mut Context<'_>,
353 ) -> Poll<std::result::Result<(), Self::Error>> {
354 Poll::Ready(Ok(()))
355 }
356 fn call(&mut self, req: http::Request<B>) -> Self::Future {
357 match req.uri().path() {
358 "/controller.proto.v1.ControllerService/OpenControlChannel" => {
359 #[allow(non_camel_case_types)]
360 struct OpenControlChannelSvc<T: ControllerService>(pub Arc<T>);
361 impl<
362 T: ControllerService,
363 > tonic::server::StreamingService<super::ControlMessage>
364 for OpenControlChannelSvc<T> {
365 type Response = super::ControlMessage;
366 type ResponseStream = T::OpenControlChannelStream;
367 type Future = BoxFuture<
368 tonic::Response<Self::ResponseStream>,
369 tonic::Status,
370 >;
371 fn call(
372 &mut self,
373 request: tonic::Request<
374 tonic::Streaming<super::ControlMessage>,
375 >,
376 ) -> Self::Future {
377 let inner = Arc::clone(&self.0);
378 let fut = async move {
379 <T as ControllerService>::open_control_channel(
380 &inner,
381 request,
382 )
383 .await
384 };
385 Box::pin(fut)
386 }
387 }
388 let accept_compression_encodings = self.accept_compression_encodings;
389 let send_compression_encodings = self.send_compression_encodings;
390 let max_decoding_message_size = self.max_decoding_message_size;
391 let max_encoding_message_size = self.max_encoding_message_size;
392 let inner = self.inner.clone();
393 let fut = async move {
394 let method = OpenControlChannelSvc(inner);
395 let codec = tonic::codec::ProstCodec::default();
396 let mut grpc = tonic::server::Grpc::new(codec)
397 .apply_compression_config(
398 accept_compression_encodings,
399 send_compression_encodings,
400 )
401 .apply_max_message_size_config(
402 max_decoding_message_size,
403 max_encoding_message_size,
404 );
405 let res = grpc.streaming(method, req).await;
406 Ok(res)
407 };
408 Box::pin(fut)
409 }
410 _ => {
411 Box::pin(async move {
412 let mut response = http::Response::new(
413 tonic::body::Body::default(),
414 );
415 let headers = response.headers_mut();
416 headers
417 .insert(
418 tonic::Status::GRPC_STATUS,
419 (tonic::Code::Unimplemented as i32).into(),
420 );
421 headers
422 .insert(
423 http::header::CONTENT_TYPE,
424 tonic::metadata::GRPC_CONTENT_TYPE,
425 );
426 Ok(response)
427 })
428 }
429 }
430 }
431 }
432 impl<T> Clone for ControllerServiceServer<T> {
433 fn clone(&self) -> Self {
434 let inner = self.inner.clone();
435 Self {
436 inner,
437 accept_compression_encodings: self.accept_compression_encodings,
438 send_compression_encodings: self.send_compression_encodings,
439 max_decoding_message_size: self.max_decoding_message_size,
440 max_encoding_message_size: self.max_encoding_message_size,
441 }
442 }
443 }
444 pub const SERVICE_NAME: &str = "controller.proto.v1.ControllerService";
446 impl<T> tonic::server::NamedService for ControllerServiceServer<T> {
447 const NAME: &'static str = SERVICE_NAME;
448 }
449}