devtools_wire_format/generated/
rs.devtools.instrument.rs1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct InstrumentRequest {
4 #[prost(message, optional, tag = "2")]
6 pub log_filter: ::core::option::Option<Filter>,
7 #[prost(message, optional, tag = "3")]
9 pub span_filter: ::core::option::Option<Filter>,
10}
11#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
14pub struct Filter {
15 #[prost(enumeration = "super::common::metadata::Level", optional, tag = "1")]
16 pub level: ::core::option::Option<i32>,
17 #[prost(string, optional, tag = "2")]
18 pub file: ::core::option::Option<::prost::alloc::string::String>,
19 #[prost(string, optional, tag = "3")]
20 pub text: ::core::option::Option<::prost::alloc::string::String>,
21}
22#[derive(Clone, PartialEq, ::prost::Message)]
31pub struct Update {
32 #[prost(message, optional, tag = "1")]
34 pub at: ::core::option::Option<::prost_types::Timestamp>,
35 #[prost(message, repeated, tag = "2")]
39 pub new_metadata: ::prost::alloc::vec::Vec<super::common::NewMetadata>,
40 #[prost(message, optional, tag = "3")]
42 pub logs_update: ::core::option::Option<super::logs::Update>,
43 #[prost(message, optional, tag = "4")]
45 pub spans_update: ::core::option::Option<super::spans::Update>,
46}
47#[allow(clippy::all)]
49pub mod instrument_server {
50 #![allow(
51 unused_variables,
52 dead_code,
53 missing_docs,
54 clippy::wildcard_imports,
55 clippy::let_unit_value,
56 )]
57 use tonic::codegen::*;
58 #[async_trait]
60 pub trait Instrument: std::marker::Send + std::marker::Sync + 'static {
61 type WatchUpdatesStream: tonic::codegen::tokio_stream::Stream<
63 Item = std::result::Result<super::Update, tonic::Status>,
64 >
65 + std::marker::Send
66 + 'static;
67 async fn watch_updates(
69 &self,
70 request: tonic::Request<super::InstrumentRequest>,
71 ) -> std::result::Result<
72 tonic::Response<Self::WatchUpdatesStream>,
73 tonic::Status,
74 >;
75 }
76 #[derive(Debug)]
78 pub struct InstrumentServer<T> {
79 inner: Arc<T>,
80 accept_compression_encodings: EnabledCompressionEncodings,
81 send_compression_encodings: EnabledCompressionEncodings,
82 max_decoding_message_size: Option<usize>,
83 max_encoding_message_size: Option<usize>,
84 }
85 impl<T> InstrumentServer<T> {
86 pub fn new(inner: T) -> Self {
87 Self::from_arc(Arc::new(inner))
88 }
89 pub fn from_arc(inner: Arc<T>) -> Self {
90 Self {
91 inner,
92 accept_compression_encodings: Default::default(),
93 send_compression_encodings: Default::default(),
94 max_decoding_message_size: None,
95 max_encoding_message_size: None,
96 }
97 }
98 pub fn with_interceptor<F>(
99 inner: T,
100 interceptor: F,
101 ) -> InterceptedService<Self, F>
102 where
103 F: tonic::service::Interceptor,
104 {
105 InterceptedService::new(Self::new(inner), interceptor)
106 }
107 #[must_use]
109 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
110 self.accept_compression_encodings.enable(encoding);
111 self
112 }
113 #[must_use]
115 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
116 self.send_compression_encodings.enable(encoding);
117 self
118 }
119 #[must_use]
123 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
124 self.max_decoding_message_size = Some(limit);
125 self
126 }
127 #[must_use]
131 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
132 self.max_encoding_message_size = Some(limit);
133 self
134 }
135 }
136 impl<T, B> tonic::codegen::Service<http::Request<B>> for InstrumentServer<T>
137 where
138 T: Instrument,
139 B: Body + std::marker::Send + 'static,
140 B::Error: Into<StdError> + std::marker::Send + 'static,
141 {
142 type Response = http::Response<tonic::body::Body>;
143 type Error = std::convert::Infallible;
144 type Future = BoxFuture<Self::Response, Self::Error>;
145 fn poll_ready(
146 &mut self,
147 _cx: &mut Context<'_>,
148 ) -> Poll<std::result::Result<(), Self::Error>> {
149 Poll::Ready(Ok(()))
150 }
151 fn call(&mut self, req: http::Request<B>) -> Self::Future {
152 match req.uri().path() {
153 "/rs.devtools.instrument.Instrument/WatchUpdates" => {
154 #[allow(non_camel_case_types)]
155 struct WatchUpdatesSvc<T: Instrument>(pub Arc<T>);
156 impl<
157 T: Instrument,
158 > tonic::server::ServerStreamingService<super::InstrumentRequest>
159 for WatchUpdatesSvc<T> {
160 type Response = super::Update;
161 type ResponseStream = T::WatchUpdatesStream;
162 type Future = BoxFuture<
163 tonic::Response<Self::ResponseStream>,
164 tonic::Status,
165 >;
166 fn call(
167 &mut self,
168 request: tonic::Request<super::InstrumentRequest>,
169 ) -> Self::Future {
170 let inner = Arc::clone(&self.0);
171 let fut = async move {
172 <T as Instrument>::watch_updates(&inner, request).await
173 };
174 Box::pin(fut)
175 }
176 }
177 let accept_compression_encodings = self.accept_compression_encodings;
178 let send_compression_encodings = self.send_compression_encodings;
179 let max_decoding_message_size = self.max_decoding_message_size;
180 let max_encoding_message_size = self.max_encoding_message_size;
181 let inner = self.inner.clone();
182 let fut = async move {
183 let method = WatchUpdatesSvc(inner);
184 let codec = tonic_prost::ProstCodec::default();
185 let mut grpc = tonic::server::Grpc::new(codec)
186 .apply_compression_config(
187 accept_compression_encodings,
188 send_compression_encodings,
189 )
190 .apply_max_message_size_config(
191 max_decoding_message_size,
192 max_encoding_message_size,
193 );
194 let res = grpc.server_streaming(method, req).await;
195 Ok(res)
196 };
197 Box::pin(fut)
198 }
199 _ => {
200 Box::pin(async move {
201 let mut response = http::Response::new(
202 tonic::body::Body::default(),
203 );
204 let headers = response.headers_mut();
205 headers
206 .insert(
207 tonic::Status::GRPC_STATUS,
208 (tonic::Code::Unimplemented as i32).into(),
209 );
210 headers
211 .insert(
212 http::header::CONTENT_TYPE,
213 tonic::metadata::GRPC_CONTENT_TYPE,
214 );
215 Ok(response)
216 })
217 }
218 }
219 }
220 }
221 impl<T> Clone for InstrumentServer<T> {
222 fn clone(&self) -> Self {
223 let inner = self.inner.clone();
224 Self {
225 inner,
226 accept_compression_encodings: self.accept_compression_encodings,
227 send_compression_encodings: self.send_compression_encodings,
228 max_decoding_message_size: self.max_decoding_message_size,
229 max_encoding_message_size: self.max_encoding_message_size,
230 }
231 }
232 }
233 pub const SERVICE_NAME: &str = "rs.devtools.instrument.Instrument";
235 impl<T> tonic::server::NamedService for InstrumentServer<T> {
236 const NAME: &'static str = SERVICE_NAME;
237 }
238}