fix(build): Remove async ready (#185)
* fix(build): Remove async ready * fix build
This commit is contained in:
+15
-14
@@ -34,13 +34,6 @@ pub(crate) fn generate(service: &Service, proto: &str) -> TokenStream {
|
|||||||
Self { inner }
|
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
|
#methods
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +103,9 @@ fn generate_unary(method: &Method, proto: &str, path: String) -> TokenStream {
|
|||||||
&mut self,
|
&mut self,
|
||||||
request: impl tonic::IntoRequest<#request>,
|
request: impl tonic::IntoRequest<#request>,
|
||||||
) -> Result<tonic::Response<#response>, tonic::Status> {
|
) -> 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 codec = tonic::codec::ProstCodec::default();
|
||||||
let path = http::uri::PathAndQuery::from_static(#path);
|
let path = http::uri::PathAndQuery::from_static(#path);
|
||||||
self.inner.unary(request.into_request(), path, codec).await
|
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,
|
&mut self,
|
||||||
request: impl tonic::IntoRequest<#request>,
|
request: impl tonic::IntoRequest<#request>,
|
||||||
) -> Result<tonic::Response<tonic::codec::Streaming<#response>>, tonic::Status> {
|
) -> 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 codec = tonic::codec::ProstCodec::default();
|
||||||
let path = http::uri::PathAndQuery::from_static(#path);
|
let path = http::uri::PathAndQuery::from_static(#path);
|
||||||
self.inner.server_streaming(request.into_request(), path, codec).await
|
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,
|
&mut self,
|
||||||
request: impl tonic::IntoStreamingRequest<Message = #request>
|
request: impl tonic::IntoStreamingRequest<Message = #request>
|
||||||
) -> Result<tonic::Response<#response>, tonic::Status> {
|
) -> Result<tonic::Response<#response>, tonic::Status> {
|
||||||
self.ready().await?;
|
self.inner.ready().await.map_err(|e| {
|
||||||
let codec = tonic::codec::ProstCodec::default();
|
tonic::Status::new(tonic::Code::Unknown, format!("Service was not ready: {}", e.into()))
|
||||||
let path = http::uri::PathAndQuery::from_static(#path);
|
})?;
|
||||||
self.inner.client_streaming(request.into_streaming_request(), path, codec).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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +163,9 @@ fn generate_streaming(method: &Method, proto: &str, path: String) -> TokenStream
|
|||||||
&mut self,
|
&mut self,
|
||||||
request: impl tonic::IntoStreamingRequest<Message = #request>
|
request: impl tonic::IntoStreamingRequest<Message = #request>
|
||||||
) -> Result<tonic::Response<tonic::codec::Streaming<#response>>, tonic::Status> {
|
) -> 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 codec = tonic::codec::ProstCodec::default();
|
||||||
let path = http::uri::PathAndQuery::from_static(#path);
|
let path = http::uri::PathAndQuery::from_static(#path);
|
||||||
self.inner.streaming(request.into_streaming_request(), path, codec).await
|
self.inner.streaming(request.into_streaming_request(), path, codec).await
|
||||||
|
|||||||
Reference in New Issue
Block a user