1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct PutFunctionRequest {
4 #[prost(string, tag = "1")]
6 pub cache_name: ::prost::alloc::string::String,
7 #[prost(string, tag = "2")]
9 pub name: ::prost::alloc::string::String,
10 #[prost(string, tag = "3")]
12 pub description: ::prost::alloc::string::String,
13 #[prost(map = "string, message", tag = "4")]
15 pub environment: ::std::collections::HashMap<
16 ::prost::alloc::string::String,
17 super::function_types::EnvironmentValue,
18 >,
19 #[prost(oneof = "put_function_request::WasmLocation", tags = "20, 21")]
20 pub wasm_location: ::core::option::Option<put_function_request::WasmLocation>,
21}
22pub mod put_function_request {
24 #[derive(Clone, PartialEq, ::prost::Oneof)]
25 pub enum WasmLocation {
26 #[prost(bytes, tag = "20")]
28 Inline(::prost::alloc::vec::Vec<u8>),
29 #[prost(message, tag = "21")]
31 WasmId(super::super::function_types::WasmId),
32 }
33}
34#[derive(Clone, PartialEq, ::prost::Message)]
35pub struct PutFunctionResponse {
36 #[prost(message, optional, tag = "1")]
37 pub function: ::core::option::Option<super::function_types::Function>,
38}
39#[derive(Clone, PartialEq, ::prost::Message)]
40pub struct PutWasmRequest {
41 #[prost(string, tag = "1")]
43 pub name: ::prost::alloc::string::String,
44 #[prost(string, tag = "2")]
46 pub description: ::prost::alloc::string::String,
47 #[prost(oneof = "put_wasm_request::WasmPutKind", tags = "22, 24")]
48 pub wasm_put_kind: ::core::option::Option<put_wasm_request::WasmPutKind>,
49}
50pub mod put_wasm_request {
52 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
53 pub struct MetadataOnly {}
54 #[derive(Clone, PartialEq, ::prost::Oneof)]
55 pub enum WasmPutKind {
56 #[prost(bytes, tag = "22")]
58 Inline(::prost::alloc::vec::Vec<u8>),
59 #[prost(message, tag = "24")]
61 MetadataOnly(MetadataOnly),
62 }
63}
64#[derive(Clone, PartialEq, ::prost::Message)]
65pub struct PutWasmResponse {
66 #[prost(message, optional, tag = "1")]
67 pub wasm: ::core::option::Option<super::function_types::Wasm>,
68}
69#[derive(Clone, Copy, PartialEq, ::prost::Message)]
70pub struct ListWasmsRequest {}
71#[derive(Clone, PartialEq, ::prost::Message)]
72pub struct ListFunctionsRequest {
73 #[prost(string, tag = "1")]
75 pub cache_name: ::prost::alloc::string::String,
76}
77#[derive(Clone, PartialEq, ::prost::Message)]
78pub struct ListFunctionVersionsRequest {
79 #[prost(string, tag = "1")]
81 pub function_id: ::prost::alloc::string::String,
82}
83pub mod function_registry_client {
85 #![allow(
86 unused_variables,
87 dead_code,
88 missing_docs,
89 clippy::wildcard_imports,
90 clippy::let_unit_value,
91 )]
92 use tonic::codegen::*;
93 use tonic::codegen::http::Uri;
94 #[derive(Debug, Clone)]
97 pub struct FunctionRegistryClient<T> {
98 inner: tonic::client::Grpc<T>,
99 }
100 impl FunctionRegistryClient<tonic::transport::Channel> {
101 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> FunctionRegistryClient<T>
112 where
113 T: tonic::client::GrpcService<tonic::body::Body>,
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 ) -> FunctionRegistryClient<InterceptedService<T, F>>
130 where
131 F: tonic::service::Interceptor,
132 T::ResponseBody: Default,
133 T: tonic::codegen::Service<
134 http::Request<tonic::body::Body>,
135 Response = http::Response<
136 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
137 >,
138 >,
139 <T as tonic::codegen::Service<
140 http::Request<tonic::body::Body>,
141 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
142 {
143 FunctionRegistryClient::new(InterceptedService::new(inner, interceptor))
144 }
145 #[must_use]
150 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
151 self.inner = self.inner.send_compressed(encoding);
152 self
153 }
154 #[must_use]
156 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
157 self.inner = self.inner.accept_compressed(encoding);
158 self
159 }
160 #[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 #[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 pub async fn put_function(
179 &mut self,
180 request: impl tonic::IntoRequest<super::PutFunctionRequest>,
181 ) -> std::result::Result<
182 tonic::Response<super::PutFunctionResponse>,
183 tonic::Status,
184 > {
185 self.inner
186 .ready()
187 .await
188 .map_err(|e| {
189 tonic::Status::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 "/function.FunctionRegistry/PutFunction",
196 );
197 let mut req = request.into_request();
198 req.extensions_mut()
199 .insert(GrpcMethod::new("function.FunctionRegistry", "PutFunction"));
200 self.inner.unary(req, path, codec).await
201 }
202 pub async fn put_wasm(
203 &mut self,
204 request: impl tonic::IntoRequest<super::PutWasmRequest>,
205 ) -> std::result::Result<
206 tonic::Response<super::PutWasmResponse>,
207 tonic::Status,
208 > {
209 self.inner
210 .ready()
211 .await
212 .map_err(|e| {
213 tonic::Status::unknown(
214 format!("Service was not ready: {}", e.into()),
215 )
216 })?;
217 let codec = tonic::codec::ProstCodec::default();
218 let path = http::uri::PathAndQuery::from_static(
219 "/function.FunctionRegistry/PutWasm",
220 );
221 let mut req = request.into_request();
222 req.extensions_mut()
223 .insert(GrpcMethod::new("function.FunctionRegistry", "PutWasm"));
224 self.inner.unary(req, path, codec).await
225 }
226 pub async fn list_functions(
227 &mut self,
228 request: impl tonic::IntoRequest<super::ListFunctionsRequest>,
229 ) -> std::result::Result<
230 tonic::Response<
231 tonic::codec::Streaming<super::super::function_types::Function>,
232 >,
233 tonic::Status,
234 > {
235 self.inner
236 .ready()
237 .await
238 .map_err(|e| {
239 tonic::Status::unknown(
240 format!("Service was not ready: {}", e.into()),
241 )
242 })?;
243 let codec = tonic::codec::ProstCodec::default();
244 let path = http::uri::PathAndQuery::from_static(
245 "/function.FunctionRegistry/ListFunctions",
246 );
247 let mut req = request.into_request();
248 req.extensions_mut()
249 .insert(GrpcMethod::new("function.FunctionRegistry", "ListFunctions"));
250 self.inner.server_streaming(req, path, codec).await
251 }
252 pub async fn list_function_versions(
253 &mut self,
254 request: impl tonic::IntoRequest<super::ListFunctionVersionsRequest>,
255 ) -> std::result::Result<
256 tonic::Response<
257 tonic::codec::Streaming<super::super::function_types::FunctionVersion>,
258 >,
259 tonic::Status,
260 > {
261 self.inner
262 .ready()
263 .await
264 .map_err(|e| {
265 tonic::Status::unknown(
266 format!("Service was not ready: {}", e.into()),
267 )
268 })?;
269 let codec = tonic::codec::ProstCodec::default();
270 let path = http::uri::PathAndQuery::from_static(
271 "/function.FunctionRegistry/ListFunctionVersions",
272 );
273 let mut req = request.into_request();
274 req.extensions_mut()
275 .insert(
276 GrpcMethod::new("function.FunctionRegistry", "ListFunctionVersions"),
277 );
278 self.inner.server_streaming(req, path, codec).await
279 }
280 pub async fn list_wasms(
281 &mut self,
282 request: impl tonic::IntoRequest<super::ListWasmsRequest>,
283 ) -> std::result::Result<
284 tonic::Response<tonic::codec::Streaming<super::super::function_types::Wasm>>,
285 tonic::Status,
286 > {
287 self.inner
288 .ready()
289 .await
290 .map_err(|e| {
291 tonic::Status::unknown(
292 format!("Service was not ready: {}", e.into()),
293 )
294 })?;
295 let codec = tonic::codec::ProstCodec::default();
296 let path = http::uri::PathAndQuery::from_static(
297 "/function.FunctionRegistry/ListWasms",
298 );
299 let mut req = request.into_request();
300 req.extensions_mut()
301 .insert(GrpcMethod::new("function.FunctionRegistry", "ListWasms"));
302 self.inner.server_streaming(req, path, codec).await
303 }
304 }
305}
306pub mod function_registry_server {
308 #![allow(
309 unused_variables,
310 dead_code,
311 missing_docs,
312 clippy::wildcard_imports,
313 clippy::let_unit_value,
314 )]
315 use tonic::codegen::*;
316 #[async_trait]
318 pub trait FunctionRegistry: std::marker::Send + std::marker::Sync + 'static {
319 async fn put_function(
322 &self,
323 request: tonic::Request<super::PutFunctionRequest>,
324 ) -> std::result::Result<
325 tonic::Response<super::PutFunctionResponse>,
326 tonic::Status,
327 >;
328 async fn put_wasm(
329 &self,
330 request: tonic::Request<super::PutWasmRequest>,
331 ) -> std::result::Result<tonic::Response<super::PutWasmResponse>, tonic::Status>;
332 type ListFunctionsStream: tonic::codegen::tokio_stream::Stream<
334 Item = std::result::Result<
335 super::super::function_types::Function,
336 tonic::Status,
337 >,
338 >
339 + std::marker::Send
340 + 'static;
341 async fn list_functions(
342 &self,
343 request: tonic::Request<super::ListFunctionsRequest>,
344 ) -> std::result::Result<
345 tonic::Response<Self::ListFunctionsStream>,
346 tonic::Status,
347 >;
348 type ListFunctionVersionsStream: tonic::codegen::tokio_stream::Stream<
350 Item = std::result::Result<
351 super::super::function_types::FunctionVersion,
352 tonic::Status,
353 >,
354 >
355 + std::marker::Send
356 + 'static;
357 async fn list_function_versions(
358 &self,
359 request: tonic::Request<super::ListFunctionVersionsRequest>,
360 ) -> std::result::Result<
361 tonic::Response<Self::ListFunctionVersionsStream>,
362 tonic::Status,
363 >;
364 type ListWasmsStream: tonic::codegen::tokio_stream::Stream<
366 Item = std::result::Result<
367 super::super::function_types::Wasm,
368 tonic::Status,
369 >,
370 >
371 + std::marker::Send
372 + 'static;
373 async fn list_wasms(
374 &self,
375 request: tonic::Request<super::ListWasmsRequest>,
376 ) -> std::result::Result<tonic::Response<Self::ListWasmsStream>, tonic::Status>;
377 }
378 #[derive(Debug)]
381 pub struct FunctionRegistryServer<T> {
382 inner: Arc<T>,
383 accept_compression_encodings: EnabledCompressionEncodings,
384 send_compression_encodings: EnabledCompressionEncodings,
385 max_decoding_message_size: Option<usize>,
386 max_encoding_message_size: Option<usize>,
387 }
388 impl<T> FunctionRegistryServer<T> {
389 pub fn new(inner: T) -> Self {
390 Self::from_arc(Arc::new(inner))
391 }
392 pub fn from_arc(inner: Arc<T>) -> Self {
393 Self {
394 inner,
395 accept_compression_encodings: Default::default(),
396 send_compression_encodings: Default::default(),
397 max_decoding_message_size: None,
398 max_encoding_message_size: None,
399 }
400 }
401 pub fn with_interceptor<F>(
402 inner: T,
403 interceptor: F,
404 ) -> InterceptedService<Self, F>
405 where
406 F: tonic::service::Interceptor,
407 {
408 InterceptedService::new(Self::new(inner), interceptor)
409 }
410 #[must_use]
412 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
413 self.accept_compression_encodings.enable(encoding);
414 self
415 }
416 #[must_use]
418 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
419 self.send_compression_encodings.enable(encoding);
420 self
421 }
422 #[must_use]
426 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
427 self.max_decoding_message_size = Some(limit);
428 self
429 }
430 #[must_use]
434 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
435 self.max_encoding_message_size = Some(limit);
436 self
437 }
438 }
439 impl<T, B> tonic::codegen::Service<http::Request<B>> for FunctionRegistryServer<T>
440 where
441 T: FunctionRegistry,
442 B: Body + std::marker::Send + 'static,
443 B::Error: Into<StdError> + std::marker::Send + 'static,
444 {
445 type Response = http::Response<tonic::body::Body>;
446 type Error = std::convert::Infallible;
447 type Future = BoxFuture<Self::Response, Self::Error>;
448 fn poll_ready(
449 &mut self,
450 _cx: &mut Context<'_>,
451 ) -> Poll<std::result::Result<(), Self::Error>> {
452 Poll::Ready(Ok(()))
453 }
454 fn call(&mut self, req: http::Request<B>) -> Self::Future {
455 match req.uri().path() {
456 "/function.FunctionRegistry/PutFunction" => {
457 #[allow(non_camel_case_types)]
458 struct PutFunctionSvc<T: FunctionRegistry>(pub Arc<T>);
459 impl<
460 T: FunctionRegistry,
461 > tonic::server::UnaryService<super::PutFunctionRequest>
462 for PutFunctionSvc<T> {
463 type Response = super::PutFunctionResponse;
464 type Future = BoxFuture<
465 tonic::Response<Self::Response>,
466 tonic::Status,
467 >;
468 fn call(
469 &mut self,
470 request: tonic::Request<super::PutFunctionRequest>,
471 ) -> Self::Future {
472 let inner = Arc::clone(&self.0);
473 let fut = async move {
474 <T as FunctionRegistry>::put_function(&inner, request).await
475 };
476 Box::pin(fut)
477 }
478 }
479 let accept_compression_encodings = self.accept_compression_encodings;
480 let send_compression_encodings = self.send_compression_encodings;
481 let max_decoding_message_size = self.max_decoding_message_size;
482 let max_encoding_message_size = self.max_encoding_message_size;
483 let inner = self.inner.clone();
484 let fut = async move {
485 let method = PutFunctionSvc(inner);
486 let codec = tonic::codec::ProstCodec::default();
487 let mut grpc = tonic::server::Grpc::new(codec)
488 .apply_compression_config(
489 accept_compression_encodings,
490 send_compression_encodings,
491 )
492 .apply_max_message_size_config(
493 max_decoding_message_size,
494 max_encoding_message_size,
495 );
496 let res = grpc.unary(method, req).await;
497 Ok(res)
498 };
499 Box::pin(fut)
500 }
501 "/function.FunctionRegistry/PutWasm" => {
502 #[allow(non_camel_case_types)]
503 struct PutWasmSvc<T: FunctionRegistry>(pub Arc<T>);
504 impl<
505 T: FunctionRegistry,
506 > tonic::server::UnaryService<super::PutWasmRequest>
507 for PutWasmSvc<T> {
508 type Response = super::PutWasmResponse;
509 type Future = BoxFuture<
510 tonic::Response<Self::Response>,
511 tonic::Status,
512 >;
513 fn call(
514 &mut self,
515 request: tonic::Request<super::PutWasmRequest>,
516 ) -> Self::Future {
517 let inner = Arc::clone(&self.0);
518 let fut = async move {
519 <T as FunctionRegistry>::put_wasm(&inner, request).await
520 };
521 Box::pin(fut)
522 }
523 }
524 let accept_compression_encodings = self.accept_compression_encodings;
525 let send_compression_encodings = self.send_compression_encodings;
526 let max_decoding_message_size = self.max_decoding_message_size;
527 let max_encoding_message_size = self.max_encoding_message_size;
528 let inner = self.inner.clone();
529 let fut = async move {
530 let method = PutWasmSvc(inner);
531 let codec = tonic::codec::ProstCodec::default();
532 let mut grpc = tonic::server::Grpc::new(codec)
533 .apply_compression_config(
534 accept_compression_encodings,
535 send_compression_encodings,
536 )
537 .apply_max_message_size_config(
538 max_decoding_message_size,
539 max_encoding_message_size,
540 );
541 let res = grpc.unary(method, req).await;
542 Ok(res)
543 };
544 Box::pin(fut)
545 }
546 "/function.FunctionRegistry/ListFunctions" => {
547 #[allow(non_camel_case_types)]
548 struct ListFunctionsSvc<T: FunctionRegistry>(pub Arc<T>);
549 impl<
550 T: FunctionRegistry,
551 > tonic::server::ServerStreamingService<super::ListFunctionsRequest>
552 for ListFunctionsSvc<T> {
553 type Response = super::super::function_types::Function;
554 type ResponseStream = T::ListFunctionsStream;
555 type Future = BoxFuture<
556 tonic::Response<Self::ResponseStream>,
557 tonic::Status,
558 >;
559 fn call(
560 &mut self,
561 request: tonic::Request<super::ListFunctionsRequest>,
562 ) -> Self::Future {
563 let inner = Arc::clone(&self.0);
564 let fut = async move {
565 <T as FunctionRegistry>::list_functions(&inner, request)
566 .await
567 };
568 Box::pin(fut)
569 }
570 }
571 let accept_compression_encodings = self.accept_compression_encodings;
572 let send_compression_encodings = self.send_compression_encodings;
573 let max_decoding_message_size = self.max_decoding_message_size;
574 let max_encoding_message_size = self.max_encoding_message_size;
575 let inner = self.inner.clone();
576 let fut = async move {
577 let method = ListFunctionsSvc(inner);
578 let codec = tonic::codec::ProstCodec::default();
579 let mut grpc = tonic::server::Grpc::new(codec)
580 .apply_compression_config(
581 accept_compression_encodings,
582 send_compression_encodings,
583 )
584 .apply_max_message_size_config(
585 max_decoding_message_size,
586 max_encoding_message_size,
587 );
588 let res = grpc.server_streaming(method, req).await;
589 Ok(res)
590 };
591 Box::pin(fut)
592 }
593 "/function.FunctionRegistry/ListFunctionVersions" => {
594 #[allow(non_camel_case_types)]
595 struct ListFunctionVersionsSvc<T: FunctionRegistry>(pub Arc<T>);
596 impl<
597 T: FunctionRegistry,
598 > tonic::server::ServerStreamingService<
599 super::ListFunctionVersionsRequest,
600 > for ListFunctionVersionsSvc<T> {
601 type Response = super::super::function_types::FunctionVersion;
602 type ResponseStream = T::ListFunctionVersionsStream;
603 type Future = BoxFuture<
604 tonic::Response<Self::ResponseStream>,
605 tonic::Status,
606 >;
607 fn call(
608 &mut self,
609 request: tonic::Request<super::ListFunctionVersionsRequest>,
610 ) -> Self::Future {
611 let inner = Arc::clone(&self.0);
612 let fut = async move {
613 <T as FunctionRegistry>::list_function_versions(
614 &inner,
615 request,
616 )
617 .await
618 };
619 Box::pin(fut)
620 }
621 }
622 let accept_compression_encodings = self.accept_compression_encodings;
623 let send_compression_encodings = self.send_compression_encodings;
624 let max_decoding_message_size = self.max_decoding_message_size;
625 let max_encoding_message_size = self.max_encoding_message_size;
626 let inner = self.inner.clone();
627 let fut = async move {
628 let method = ListFunctionVersionsSvc(inner);
629 let codec = tonic::codec::ProstCodec::default();
630 let mut grpc = tonic::server::Grpc::new(codec)
631 .apply_compression_config(
632 accept_compression_encodings,
633 send_compression_encodings,
634 )
635 .apply_max_message_size_config(
636 max_decoding_message_size,
637 max_encoding_message_size,
638 );
639 let res = grpc.server_streaming(method, req).await;
640 Ok(res)
641 };
642 Box::pin(fut)
643 }
644 "/function.FunctionRegistry/ListWasms" => {
645 #[allow(non_camel_case_types)]
646 struct ListWasmsSvc<T: FunctionRegistry>(pub Arc<T>);
647 impl<
648 T: FunctionRegistry,
649 > tonic::server::ServerStreamingService<super::ListWasmsRequest>
650 for ListWasmsSvc<T> {
651 type Response = super::super::function_types::Wasm;
652 type ResponseStream = T::ListWasmsStream;
653 type Future = BoxFuture<
654 tonic::Response<Self::ResponseStream>,
655 tonic::Status,
656 >;
657 fn call(
658 &mut self,
659 request: tonic::Request<super::ListWasmsRequest>,
660 ) -> Self::Future {
661 let inner = Arc::clone(&self.0);
662 let fut = async move {
663 <T as FunctionRegistry>::list_wasms(&inner, request).await
664 };
665 Box::pin(fut)
666 }
667 }
668 let accept_compression_encodings = self.accept_compression_encodings;
669 let send_compression_encodings = self.send_compression_encodings;
670 let max_decoding_message_size = self.max_decoding_message_size;
671 let max_encoding_message_size = self.max_encoding_message_size;
672 let inner = self.inner.clone();
673 let fut = async move {
674 let method = ListWasmsSvc(inner);
675 let codec = tonic::codec::ProstCodec::default();
676 let mut grpc = tonic::server::Grpc::new(codec)
677 .apply_compression_config(
678 accept_compression_encodings,
679 send_compression_encodings,
680 )
681 .apply_max_message_size_config(
682 max_decoding_message_size,
683 max_encoding_message_size,
684 );
685 let res = grpc.server_streaming(method, req).await;
686 Ok(res)
687 };
688 Box::pin(fut)
689 }
690 _ => {
691 Box::pin(async move {
692 let mut response = http::Response::new(
693 tonic::body::Body::default(),
694 );
695 let headers = response.headers_mut();
696 headers
697 .insert(
698 tonic::Status::GRPC_STATUS,
699 (tonic::Code::Unimplemented as i32).into(),
700 );
701 headers
702 .insert(
703 http::header::CONTENT_TYPE,
704 tonic::metadata::GRPC_CONTENT_TYPE,
705 );
706 Ok(response)
707 })
708 }
709 }
710 }
711 }
712 impl<T> Clone for FunctionRegistryServer<T> {
713 fn clone(&self) -> Self {
714 let inner = self.inner.clone();
715 Self {
716 inner,
717 accept_compression_encodings: self.accept_compression_encodings,
718 send_compression_encodings: self.send_compression_encodings,
719 max_decoding_message_size: self.max_decoding_message_size,
720 max_encoding_message_size: self.max_encoding_message_size,
721 }
722 }
723 }
724 pub const SERVICE_NAME: &str = "function.FunctionRegistry";
726 impl<T> tonic::server::NamedService for FunctionRegistryServer<T> {
727 const NAME: &'static str = SERVICE_NAME;
728 }
729}