fix(build): Remove async ready (#185)

* fix(build): Remove async ready

* fix build
This commit is contained in:
Lucio Franco
2019-12-13 18:19:23 -05:00
committed by GitHub
parent b90c340800
commit 97d5363e2b
+15 -14
View File
@@ -34,13 +34,6 @@ pub(crate) fn generate(service: &Service, proto: &str) -> TokenStream {
Self { inner }
}
/// Check if the service is ready.
pub async fn ready(&mut self) -> Result<(), tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})
}
#methods
}
@@ -110,7 +103,9 @@ fn generate_unary(method: &Method, proto: &str, path: String) -> TokenStream {
&mut self,
request: impl tonic::IntoRequest<#request>,
) -> Result<tonic::Response<#response>, tonic::Status> {
self.ready().await?;
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(#path);
self.inner.unary(request.into_request(), path, codec).await
@@ -128,7 +123,9 @@ fn generate_server_streaming(method: &Method, proto: &str, path: String) -> Toke
&mut self,
request: impl tonic::IntoRequest<#request>,
) -> Result<tonic::Response<tonic::codec::Streaming<#response>>, tonic::Status> {
self.ready().await?;
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(#path);
self.inner.server_streaming(request.into_request(), path, codec).await
@@ -146,10 +143,12 @@ fn generate_client_streaming(method: &Method, proto: &str, path: String) -> Toke
&mut self,
request: impl tonic::IntoStreamingRequest<Message = #request>
) -> Result<tonic::Response<#response>, tonic::Status> {
self.ready().await?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(#path);
self.inner.client_streaming(request.into_streaming_request(), path, codec).await
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(#path);
self.inner.client_streaming(request.into_streaming_request(), path, codec).await
}
}
}
@@ -164,7 +163,9 @@ fn generate_streaming(method: &Method, proto: &str, path: String) -> TokenStream
&mut self,
request: impl tonic::IntoStreamingRequest<Message = #request>
) -> Result<tonic::Response<tonic::codec::Streaming<#response>>, tonic::Status> {
self.ready().await?;
self.inner.ready().await.map_err(|e| {
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(#path);
self.inner.streaming(request.into_streaming_request(), path, codec).await