/// The request message containing the user's name. #[derive(Clone, PartialEq, ::prost::Message)] pub struct GreeterRequest { #[prost(string, tag="1")] pub name: ::prost::alloc::string::String, } /// The response message containing the greetings #[derive(Clone, PartialEq, ::prost::Message)] pub struct GreeterReply { #[prost(string, tag="1")] pub message: ::prost::alloc::string::String, } /// Generated client implementations. pub mod greeter_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] use dubbo::codegen::*; #[derive(Debug, Clone, Default)] pub struct GreeterClient { inner: TripleClient, uri: String, } impl GreeterClient { pub fn new() -> Self { Self { inner: TripleClient::new(), uri: "".to_string(), } } pub fn with_uri(mut self, uri: String) -> Self { self.uri = uri.clone(); self.inner = self.inner.with_host(uri); self } /// unary pub async fn greet( &mut self, request: Request, ) -> Result, dubbo::status::Status> { let codec = dubbo::codegen::ProstCodec::< super::GreeterRequest, super::GreeterReply, >::default(); let path = http::uri::PathAndQuery::from_static( "/org.apache.dubbo.sample.tri.Greeter/greet", ); self.inner.unary(request, codec, path).await } } } /// Generated server implementations. pub mod greeter_server { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] use dubbo::codegen::*; ///Generated trait containing gRPC methods that should be implemented for use with GreeterServer. #[async_trait] pub trait Greeter: Send + Sync + 'static { /// unary async fn greet( &self, request: Request, ) -> Result, dubbo::status::Status>; } #[derive(Debug)] pub struct GreeterServer { inner: _Inner, invoker: Option, } struct _Inner(Arc); impl GreeterServer { pub fn new(inner: T) -> Self { Self { inner: _Inner(Arc::new(inner)), invoker: None, } } } impl Service> for GreeterServer where T: Greeter, B: Body + Send + 'static, B::Error: Into + Send + 'static, I: Invoker + Send + 'static, { type Response = http::Response; type Error = std::convert::Infallible; type Future = BoxFuture; fn poll_ready( &mut self, _cx: &mut Context<'_>, ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { let inner = self.inner.clone(); match req.uri().path() { "/org.apache.dubbo.sample.tri.Greeter/greet" => { #[allow(non_camel_case_types)] struct greetServer { inner: _Inner, } impl UnarySvc for greetServer { type Response = super::GreeterReply; type Future = BoxFuture< Response, dubbo::status::Status, >; fn call( &mut self, request: Request, ) -> Self::Future { let inner = self.inner.0.clone(); let fut = async move { inner.greet(request).await }; Box::pin(fut) } } let fut = async move { let mut server = TripleServer::new( dubbo::codegen::ProstCodec::< super::GreeterReply, super::GreeterRequest, >::default(), ); let res = server.unary(greetServer { inner }, req).await; Ok(res) }; Box::pin(fut) } _ => { Box::pin(async move { Ok( http::Response::builder() .status(200) .header("grpc-status", "12") .header("content-type", "application/grpc") .body(empty_body()) .unwrap(), ) }) } } } } impl Clone for GreeterServer { fn clone(&self) -> Self { let inner = self.inner.clone(); Self { inner, invoker: None } } } impl Clone for _Inner { fn clone(&self) -> Self { Self(self.0.clone()) } } impl std::fmt::Debug for _Inner { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:?}", self.0) } } pub fn register_server(server: T) { let s = GreeterServer::<_, TripleInvoker>::new(server); dubbo::protocol::triple::TRIPLE_SERVICES .write() .unwrap() .insert( "org.apache.dubbo.sample.tri.Greeter".to_string(), dubbo::utils::boxed_clone::BoxCloneService::new(s), ); } }