hds_console_api/generated/
rs.tokio.console.trace.rs

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