@@ -34,13 +34,6 @@ pub(crate) fn generate(service: &Service, proto: &str) -> TokenStream {
3434 Self { inner }
3535 }
3636
37- /// Check if the service is ready.
38- pub async fn ready( & mut self ) -> Result <( ) , tonic:: Status > {
39- self . inner. ready( ) . await . map_err( |e| {
40- tonic:: Status :: new( tonic:: Code :: Unknown , format!( "Service was not ready: {}" , e. into( ) ) )
41- } )
42- }
43-
4437 #methods
4538 }
4639
@@ -110,7 +103,9 @@ fn generate_unary(method: &Method, proto: &str, path: String) -> TokenStream {
110103 & mut self ,
111104 request: impl tonic:: IntoRequest <#request>,
112105 ) -> Result <tonic:: Response <#response>, tonic:: Status > {
113- self . ready( ) . await ?;
106+ self . inner. ready( ) . await . map_err( |e| {
107+ tonic:: Status :: new( tonic:: Code :: Unknown , format!( "Service was not ready: {}" , e. into( ) ) )
108+ } ) ?;
114109 let codec = tonic:: codec:: ProstCodec :: default ( ) ;
115110 let path = http:: uri:: PathAndQuery :: from_static( #path) ;
116111 self . inner. unary( request. into_request( ) , path, codec) . await
@@ -128,7 +123,9 @@ fn generate_server_streaming(method: &Method, proto: &str, path: String) -> Toke
128123 & mut self ,
129124 request: impl tonic:: IntoRequest <#request>,
130125 ) -> Result <tonic:: Response <tonic:: codec:: Streaming <#response>>, tonic:: Status > {
131- self . ready( ) . await ?;
126+ self . inner. ready( ) . await . map_err( |e| {
127+ tonic:: Status :: new( tonic:: Code :: Unknown , format!( "Service was not ready: {}" , e. into( ) ) )
128+ } ) ?;
132129 let codec = tonic:: codec:: ProstCodec :: default ( ) ;
133130 let path = http:: uri:: PathAndQuery :: from_static( #path) ;
134131 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
146143 & mut self ,
147144 request: impl tonic:: IntoStreamingRequest <Message = #request>
148145 ) -> Result <tonic:: Response <#response>, tonic:: Status > {
149- self . ready( ) . await ?;
150- let codec = tonic:: codec:: ProstCodec :: default ( ) ;
151- let path = http:: uri:: PathAndQuery :: from_static( #path) ;
152- self . inner. client_streaming( request. into_streaming_request( ) , path, codec) . await
146+ self . inner. ready( ) . await . map_err( |e| {
147+ tonic:: Status :: new( tonic:: Code :: Unknown , format!( "Service was not ready: {}" , e. into( ) ) )
148+ } ) ?;
149+ let codec = tonic:: codec:: ProstCodec :: default ( ) ;
150+ let path = http:: uri:: PathAndQuery :: from_static( #path) ;
151+ self . inner. client_streaming( request. into_streaming_request( ) , path, codec) . await
153152 }
154153 }
155154}
@@ -164,7 +163,9 @@ fn generate_streaming(method: &Method, proto: &str, path: String) -> TokenStream
164163 & mut self ,
165164 request: impl tonic:: IntoStreamingRequest <Message = #request>
166165 ) -> Result <tonic:: Response <tonic:: codec:: Streaming <#response>>, tonic:: Status > {
167- self . ready( ) . await ?;
166+ self . inner. ready( ) . await . map_err( |e| {
167+ tonic:: Status :: new( tonic:: Code :: Unknown , format!( "Service was not ready: {}" , e. into( ) ) )
168+ } ) ?;
168169 let codec = tonic:: codec:: ProstCodec :: default ( ) ;
169170 let path = http:: uri:: PathAndQuery :: from_static( #path) ;
170171 self . inner. streaming( request. into_streaming_request( ) , path, codec) . await
0 commit comments