Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
fix(build): Remove async ready (hyperium#185)
Browse files Browse the repository at this point in the history
* fix(build): Remove async ready

* fix build
  • Loading branch information
LucioFranco authored and rabbitinspace committed Jan 1, 2020
1 parent 70b12c0 commit f19bc87
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tonic-build/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
}
}
Expand All @@ -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
Expand Down

0 comments on commit f19bc87

Please sign in to comment.