console_api/generated/
rs.tokio.console.trace.rs

1// This file is @generated by prost-build.
2/// Start watching trace events with the provided filter.
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#[derive(Clone, PartialEq, ::prost::Message)]
11pub struct TraceEvent {
12    /// A trace event
13    #[prost(oneof = "trace_event::Event", tags = "1, 2, 3, 4, 5, 6")]
14    pub event: ::core::option::Option<trace_event::Event>,
15}
16/// Nested message and enum types in `TraceEvent`.
17pub mod trace_event {
18    /// `RegisterThreads` signals that a new thread was registered.
19    #[derive(Clone, PartialEq, ::prost::Message)]
20    pub struct RegisterThreads {
21        /// `names` maps the registered thread id's to their associated name.
22        #[prost(map = "uint64, string", tag = "1")]
23        pub names: ::std::collections::HashMap<u64, ::prost::alloc::string::String>,
24    }
25    /// `Enter` signals that a span was entered.
26    #[derive(Clone, Copy, PartialEq, ::prost::Message)]
27    pub struct Enter {
28        /// `span_id` identifies the span that was entered.
29        #[prost(message, optional, tag = "1")]
30        pub span_id: ::core::option::Option<super::super::common::SpanId>,
31        /// `thread_id` identifies who entered the span.
32        #[prost(uint64, tag = "2")]
33        pub thread_id: u64,
34        /// `at` identifies when the span was entered.
35        #[prost(message, optional, tag = "3")]
36        pub at: ::core::option::Option<::prost_types::Timestamp>,
37    }
38    /// `Exit` signals that a span was exited.
39    #[derive(Clone, Copy, PartialEq, ::prost::Message)]
40    pub struct Exit {
41        /// `span_id` identifies the span that was exited.
42        #[prost(message, optional, tag = "1")]
43        pub span_id: ::core::option::Option<super::super::common::SpanId>,
44        /// `thread_id` identifies who exited the span.
45        #[prost(uint64, tag = "2")]
46        pub thread_id: u64,
47        /// `at` identifies when the span was exited.
48        #[prost(message, optional, tag = "3")]
49        pub at: ::core::option::Option<::prost_types::Timestamp>,
50    }
51    /// `Close` signals that a span was closed.
52    #[derive(Clone, Copy, PartialEq, ::prost::Message)]
53    pub struct Close {
54        /// `span_id` identifies the span that was closed.
55        #[prost(message, optional, tag = "1")]
56        pub span_id: ::core::option::Option<super::super::common::SpanId>,
57        /// `at` identifies when the span was closed.
58        #[prost(message, optional, tag = "2")]
59        pub at: ::core::option::Option<::prost_types::Timestamp>,
60    }
61    /// A trace event
62    #[derive(Clone, PartialEq, ::prost::Oneof)]
63    pub enum Event {
64        /// A new thread was registered.
65        #[prost(message, tag = "1")]
66        RegisterThread(RegisterThreads),
67        /// A new span metadata was registered.
68        #[prost(message, tag = "2")]
69        RegisterMetadata(super::super::common::RegisterMetadata),
70        /// A span was created.
71        #[prost(message, tag = "3")]
72        NewSpan(super::super::common::Span),
73        /// A span was entered.
74        #[prost(message, tag = "4")]
75        EnterSpan(Enter),
76        /// A span was exited.
77        #[prost(message, tag = "5")]
78        ExitSpan(Exit),
79        /// A span was closed.
80        #[prost(message, tag = "6")]
81        CloseSpan(Close),
82    }
83}
84/// Generated client implementations.
85pub mod trace_client {
86    #![allow(
87        unused_variables,
88        dead_code,
89        missing_docs,
90        clippy::wildcard_imports,
91        clippy::let_unit_value,
92    )]
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> + std::marker::Send + 'static,
116        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::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> + std::marker::Send + std::marker::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::unknown(
189                        format!("Service was not ready: {}", e.into()),
190                    )
191                })?;
192            let codec = tonic::codec::ProstCodec::default();
193            let path = http::uri::PathAndQuery::from_static(
194                "/rs.tokio.console.trace.Trace/Watch",
195            );
196            let mut req = request.into_request();
197            req.extensions_mut()
198                .insert(GrpcMethod::new("rs.tokio.console.trace.Trace", "Watch"));
199            self.inner.server_streaming(req, path, codec).await
200        }
201    }
202}
203/// Generated server implementations.
204pub mod trace_server {
205    #![allow(
206        unused_variables,
207        dead_code,
208        missing_docs,
209        clippy::wildcard_imports,
210        clippy::let_unit_value,
211    )]
212    use tonic::codegen::*;
213    /// Generated trait containing gRPC methods that should be implemented for use with TraceServer.
214    #[async_trait]
215    pub trait Trace: std::marker::Send + std::marker::Sync + 'static {
216        /// Server streaming response type for the Watch method.
217        type WatchStream: tonic::codegen::tokio_stream::Stream<
218                Item = std::result::Result<super::TraceEvent, tonic::Status>,
219            >
220            + std::marker::Send
221            + 'static;
222        /// Produces a stream of trace events for the given filter.
223        async fn watch(
224            &self,
225            request: tonic::Request<super::WatchRequest>,
226        ) -> std::result::Result<tonic::Response<Self::WatchStream>, tonic::Status>;
227    }
228    /// Allows observers to stream trace events for a given `WatchRequest` filter.
229    #[derive(Debug)]
230    pub struct TraceServer<T> {
231        inner: Arc<T>,
232        accept_compression_encodings: EnabledCompressionEncodings,
233        send_compression_encodings: EnabledCompressionEncodings,
234        max_decoding_message_size: Option<usize>,
235        max_encoding_message_size: Option<usize>,
236    }
237    impl<T> TraceServer<T> {
238        pub fn new(inner: T) -> Self {
239            Self::from_arc(Arc::new(inner))
240        }
241        pub fn from_arc(inner: Arc<T>) -> Self {
242            Self {
243                inner,
244                accept_compression_encodings: Default::default(),
245                send_compression_encodings: Default::default(),
246                max_decoding_message_size: None,
247                max_encoding_message_size: None,
248            }
249        }
250        pub fn with_interceptor<F>(
251            inner: T,
252            interceptor: F,
253        ) -> InterceptedService<Self, F>
254        where
255            F: tonic::service::Interceptor,
256        {
257            InterceptedService::new(Self::new(inner), interceptor)
258        }
259        /// Enable decompressing requests with the given encoding.
260        #[must_use]
261        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
262            self.accept_compression_encodings.enable(encoding);
263            self
264        }
265        /// Compress responses with the given encoding, if the client supports it.
266        #[must_use]
267        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
268            self.send_compression_encodings.enable(encoding);
269            self
270        }
271        /// Limits the maximum size of a decoded message.
272        ///
273        /// Default: `4MB`
274        #[must_use]
275        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
276            self.max_decoding_message_size = Some(limit);
277            self
278        }
279        /// Limits the maximum size of an encoded message.
280        ///
281        /// Default: `usize::MAX`
282        #[must_use]
283        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
284            self.max_encoding_message_size = Some(limit);
285            self
286        }
287    }
288    impl<T, B> tonic::codegen::Service<http::Request<B>> for TraceServer<T>
289    where
290        T: Trace,
291        B: Body + std::marker::Send + 'static,
292        B::Error: Into<StdError> + std::marker::Send + 'static,
293    {
294        type Response = http::Response<tonic::body::BoxBody>;
295        type Error = std::convert::Infallible;
296        type Future = BoxFuture<Self::Response, Self::Error>;
297        fn poll_ready(
298            &mut self,
299            _cx: &mut Context<'_>,
300        ) -> Poll<std::result::Result<(), Self::Error>> {
301            Poll::Ready(Ok(()))
302        }
303        fn call(&mut self, req: http::Request<B>) -> Self::Future {
304            match req.uri().path() {
305                "/rs.tokio.console.trace.Trace/Watch" => {
306                    #[allow(non_camel_case_types)]
307                    struct WatchSvc<T: Trace>(pub Arc<T>);
308                    impl<
309                        T: Trace,
310                    > tonic::server::ServerStreamingService<super::WatchRequest>
311                    for WatchSvc<T> {
312                        type Response = super::TraceEvent;
313                        type ResponseStream = T::WatchStream;
314                        type Future = BoxFuture<
315                            tonic::Response<Self::ResponseStream>,
316                            tonic::Status,
317                        >;
318                        fn call(
319                            &mut self,
320                            request: tonic::Request<super::WatchRequest>,
321                        ) -> Self::Future {
322                            let inner = Arc::clone(&self.0);
323                            let fut = async move {
324                                <T as Trace>::watch(&inner, request).await
325                            };
326                            Box::pin(fut)
327                        }
328                    }
329                    let accept_compression_encodings = self.accept_compression_encodings;
330                    let send_compression_encodings = self.send_compression_encodings;
331                    let max_decoding_message_size = self.max_decoding_message_size;
332                    let max_encoding_message_size = self.max_encoding_message_size;
333                    let inner = self.inner.clone();
334                    let fut = async move {
335                        let method = WatchSvc(inner);
336                        let codec = tonic::codec::ProstCodec::default();
337                        let mut grpc = tonic::server::Grpc::new(codec)
338                            .apply_compression_config(
339                                accept_compression_encodings,
340                                send_compression_encodings,
341                            )
342                            .apply_max_message_size_config(
343                                max_decoding_message_size,
344                                max_encoding_message_size,
345                            );
346                        let res = grpc.server_streaming(method, req).await;
347                        Ok(res)
348                    };
349                    Box::pin(fut)
350                }
351                _ => {
352                    Box::pin(async move {
353                        let mut response = http::Response::new(empty_body());
354                        let headers = response.headers_mut();
355                        headers
356                            .insert(
357                                tonic::Status::GRPC_STATUS,
358                                (tonic::Code::Unimplemented as i32).into(),
359                            );
360                        headers
361                            .insert(
362                                http::header::CONTENT_TYPE,
363                                tonic::metadata::GRPC_CONTENT_TYPE,
364                            );
365                        Ok(response)
366                    })
367                }
368            }
369        }
370    }
371    impl<T> Clone for TraceServer<T> {
372        fn clone(&self) -> Self {
373            let inner = self.inner.clone();
374            Self {
375                inner,
376                accept_compression_encodings: self.accept_compression_encodings,
377                send_compression_encodings: self.send_compression_encodings,
378                max_decoding_message_size: self.max_decoding_message_size,
379                max_encoding_message_size: self.max_encoding_message_size,
380            }
381        }
382    }
383    /// Generated gRPC service name
384    pub const SERVICE_NAME: &str = "rs.tokio.console.trace.Trace";
385    impl<T> tonic::server::NamedService for TraceServer<T> {
386        const NAME: &'static str = SERVICE_NAME;
387    }
388}