1#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
3pub struct GetRequest {
4 #[prost(string, tag = "1")]
5 pub key: ::prost::alloc::string::String,
6}
7#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
8pub struct GetResponse {
9 #[prost(bytes = "vec", optional, tag = "1")]
10 pub value: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
11}
12#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
13pub struct RemoveRequest {
14 #[prost(string, tag = "1")]
15 pub key: ::prost::alloc::string::String,
16}
17#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
18pub struct RemoveResponse {}
19pub mod groupcache_client {
21 #![allow(
22 unused_variables,
23 dead_code,
24 missing_docs,
25 clippy::wildcard_imports,
26 clippy::let_unit_value,
27 )]
28 use tonic::codegen::*;
29 use tonic::codegen::http::Uri;
30 #[derive(Debug, Clone)]
31 pub struct GroupcacheClient<T> {
32 inner: tonic::client::Grpc<T>,
33 }
34 impl GroupcacheClient<tonic::transport::Channel> {
35 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
37 where
38 D: TryInto<tonic::transport::Endpoint>,
39 D::Error: Into<StdError>,
40 {
41 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
42 Ok(Self::new(conn))
43 }
44 }
45 impl<T> GroupcacheClient<T>
46 where
47 T: tonic::client::GrpcService<tonic::body::Body>,
48 T::Error: Into<StdError>,
49 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
50 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
51 {
52 pub fn new(inner: T) -> Self {
53 let inner = tonic::client::Grpc::new(inner);
54 Self { inner }
55 }
56 pub fn with_origin(inner: T, origin: Uri) -> Self {
57 let inner = tonic::client::Grpc::with_origin(inner, origin);
58 Self { inner }
59 }
60 pub fn with_interceptor<F>(
61 inner: T,
62 interceptor: F,
63 ) -> GroupcacheClient<InterceptedService<T, F>>
64 where
65 F: tonic::service::Interceptor,
66 T::ResponseBody: Default,
67 T: tonic::codegen::Service<
68 http::Request<tonic::body::Body>,
69 Response = http::Response<
70 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
71 >,
72 >,
73 <T as tonic::codegen::Service<
74 http::Request<tonic::body::Body>,
75 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
76 {
77 GroupcacheClient::new(InterceptedService::new(inner, interceptor))
78 }
79 #[must_use]
84 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
85 self.inner = self.inner.send_compressed(encoding);
86 self
87 }
88 #[must_use]
90 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
91 self.inner = self.inner.accept_compressed(encoding);
92 self
93 }
94 #[must_use]
98 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
99 self.inner = self.inner.max_decoding_message_size(limit);
100 self
101 }
102 #[must_use]
106 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
107 self.inner = self.inner.max_encoding_message_size(limit);
108 self
109 }
110 pub async fn get(
111 &mut self,
112 request: impl tonic::IntoRequest<super::GetRequest>,
113 ) -> std::result::Result<tonic::Response<super::GetResponse>, tonic::Status> {
114 self.inner
115 .ready()
116 .await
117 .map_err(|e| {
118 tonic::Status::unknown(
119 format!("Service was not ready: {}", e.into()),
120 )
121 })?;
122 let codec = tonic_prost::ProstCodec::default();
123 let path = http::uri::PathAndQuery::from_static(
124 "/groupcache_pb.Groupcache/Get",
125 );
126 let mut req = request.into_request();
127 req.extensions_mut()
128 .insert(GrpcMethod::new("groupcache_pb.Groupcache", "Get"));
129 self.inner.unary(req, path, codec).await
130 }
131 pub async fn remove(
132 &mut self,
133 request: impl tonic::IntoRequest<super::RemoveRequest>,
134 ) -> std::result::Result<tonic::Response<super::RemoveResponse>, tonic::Status> {
135 self.inner
136 .ready()
137 .await
138 .map_err(|e| {
139 tonic::Status::unknown(
140 format!("Service was not ready: {}", e.into()),
141 )
142 })?;
143 let codec = tonic_prost::ProstCodec::default();
144 let path = http::uri::PathAndQuery::from_static(
145 "/groupcache_pb.Groupcache/Remove",
146 );
147 let mut req = request.into_request();
148 req.extensions_mut()
149 .insert(GrpcMethod::new("groupcache_pb.Groupcache", "Remove"));
150 self.inner.unary(req, path, codec).await
151 }
152 }
153}
154pub mod groupcache_server {
156 #![allow(
157 unused_variables,
158 dead_code,
159 missing_docs,
160 clippy::wildcard_imports,
161 clippy::let_unit_value,
162 )]
163 use tonic::codegen::*;
164 #[async_trait]
166 pub trait Groupcache: std::marker::Send + std::marker::Sync + 'static {
167 async fn get(
168 &self,
169 request: tonic::Request<super::GetRequest>,
170 ) -> std::result::Result<tonic::Response<super::GetResponse>, tonic::Status>;
171 async fn remove(
172 &self,
173 request: tonic::Request<super::RemoveRequest>,
174 ) -> std::result::Result<tonic::Response<super::RemoveResponse>, tonic::Status>;
175 }
176 #[derive(Debug)]
177 pub struct GroupcacheServer<T> {
178 inner: Arc<T>,
179 accept_compression_encodings: EnabledCompressionEncodings,
180 send_compression_encodings: EnabledCompressionEncodings,
181 max_decoding_message_size: Option<usize>,
182 max_encoding_message_size: Option<usize>,
183 }
184 impl<T> GroupcacheServer<T> {
185 pub fn new(inner: T) -> Self {
186 Self::from_arc(Arc::new(inner))
187 }
188 pub fn from_arc(inner: Arc<T>) -> Self {
189 Self {
190 inner,
191 accept_compression_encodings: Default::default(),
192 send_compression_encodings: Default::default(),
193 max_decoding_message_size: None,
194 max_encoding_message_size: None,
195 }
196 }
197 pub fn with_interceptor<F>(
198 inner: T,
199 interceptor: F,
200 ) -> InterceptedService<Self, F>
201 where
202 F: tonic::service::Interceptor,
203 {
204 InterceptedService::new(Self::new(inner), interceptor)
205 }
206 #[must_use]
208 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
209 self.accept_compression_encodings.enable(encoding);
210 self
211 }
212 #[must_use]
214 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
215 self.send_compression_encodings.enable(encoding);
216 self
217 }
218 #[must_use]
222 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
223 self.max_decoding_message_size = Some(limit);
224 self
225 }
226 #[must_use]
230 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
231 self.max_encoding_message_size = Some(limit);
232 self
233 }
234 }
235 impl<T, B> tonic::codegen::Service<http::Request<B>> for GroupcacheServer<T>
236 where
237 T: Groupcache,
238 B: Body + std::marker::Send + 'static,
239 B::Error: Into<StdError> + std::marker::Send + 'static,
240 {
241 type Response = http::Response<tonic::body::Body>;
242 type Error = std::convert::Infallible;
243 type Future = BoxFuture<Self::Response, Self::Error>;
244 fn poll_ready(
245 &mut self,
246 _cx: &mut Context<'_>,
247 ) -> Poll<std::result::Result<(), Self::Error>> {
248 Poll::Ready(Ok(()))
249 }
250 fn call(&mut self, req: http::Request<B>) -> Self::Future {
251 match req.uri().path() {
252 "/groupcache_pb.Groupcache/Get" => {
253 #[allow(non_camel_case_types)]
254 struct GetSvc<T: Groupcache>(pub Arc<T>);
255 impl<T: Groupcache> tonic::server::UnaryService<super::GetRequest>
256 for GetSvc<T> {
257 type Response = super::GetResponse;
258 type Future = BoxFuture<
259 tonic::Response<Self::Response>,
260 tonic::Status,
261 >;
262 fn call(
263 &mut self,
264 request: tonic::Request<super::GetRequest>,
265 ) -> Self::Future {
266 let inner = Arc::clone(&self.0);
267 let fut = async move {
268 <T as Groupcache>::get(&inner, request).await
269 };
270 Box::pin(fut)
271 }
272 }
273 let accept_compression_encodings = self.accept_compression_encodings;
274 let send_compression_encodings = self.send_compression_encodings;
275 let max_decoding_message_size = self.max_decoding_message_size;
276 let max_encoding_message_size = self.max_encoding_message_size;
277 let inner = self.inner.clone();
278 let fut = async move {
279 let method = GetSvc(inner);
280 let codec = tonic_prost::ProstCodec::default();
281 let mut grpc = tonic::server::Grpc::new(codec)
282 .apply_compression_config(
283 accept_compression_encodings,
284 send_compression_encodings,
285 )
286 .apply_max_message_size_config(
287 max_decoding_message_size,
288 max_encoding_message_size,
289 );
290 let res = grpc.unary(method, req).await;
291 Ok(res)
292 };
293 Box::pin(fut)
294 }
295 "/groupcache_pb.Groupcache/Remove" => {
296 #[allow(non_camel_case_types)]
297 struct RemoveSvc<T: Groupcache>(pub Arc<T>);
298 impl<T: Groupcache> tonic::server::UnaryService<super::RemoveRequest>
299 for RemoveSvc<T> {
300 type Response = super::RemoveResponse;
301 type Future = BoxFuture<
302 tonic::Response<Self::Response>,
303 tonic::Status,
304 >;
305 fn call(
306 &mut self,
307 request: tonic::Request<super::RemoveRequest>,
308 ) -> Self::Future {
309 let inner = Arc::clone(&self.0);
310 let fut = async move {
311 <T as Groupcache>::remove(&inner, request).await
312 };
313 Box::pin(fut)
314 }
315 }
316 let accept_compression_encodings = self.accept_compression_encodings;
317 let send_compression_encodings = self.send_compression_encodings;
318 let max_decoding_message_size = self.max_decoding_message_size;
319 let max_encoding_message_size = self.max_encoding_message_size;
320 let inner = self.inner.clone();
321 let fut = async move {
322 let method = RemoveSvc(inner);
323 let codec = tonic_prost::ProstCodec::default();
324 let mut grpc = tonic::server::Grpc::new(codec)
325 .apply_compression_config(
326 accept_compression_encodings,
327 send_compression_encodings,
328 )
329 .apply_max_message_size_config(
330 max_decoding_message_size,
331 max_encoding_message_size,
332 );
333 let res = grpc.unary(method, req).await;
334 Ok(res)
335 };
336 Box::pin(fut)
337 }
338 _ => {
339 Box::pin(async move {
340 let mut response = http::Response::new(
341 tonic::body::Body::default(),
342 );
343 let headers = response.headers_mut();
344 headers
345 .insert(
346 tonic::Status::GRPC_STATUS,
347 (tonic::Code::Unimplemented as i32).into(),
348 );
349 headers
350 .insert(
351 http::header::CONTENT_TYPE,
352 tonic::metadata::GRPC_CONTENT_TYPE,
353 );
354 Ok(response)
355 })
356 }
357 }
358 }
359 }
360 impl<T> Clone for GroupcacheServer<T> {
361 fn clone(&self) -> Self {
362 let inner = self.inner.clone();
363 Self {
364 inner,
365 accept_compression_encodings: self.accept_compression_encodings,
366 send_compression_encodings: self.send_compression_encodings,
367 max_decoding_message_size: self.max_decoding_message_size,
368 max_encoding_message_size: self.max_encoding_message_size,
369 }
370 }
371 }
372 pub const SERVICE_NAME: &str = "groupcache_pb.Groupcache";
374 impl<T> tonic::server::NamedService for GroupcacheServer<T> {
375 const NAME: &'static str = SERVICE_NAME;
376 }
377}