File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,7 +139,14 @@ where
139139 self . state . transport_stats . load ( )
140140 }
141141
142- pub async fn request ( & self , message : Bytes ) -> Result < Bytes , ReqError > {
142+ /// Send a request, return the oneshot channel to receive the response.
143+ ///
144+ /// It may fail if the underlying socket driver has been closed, or if high water mark is
145+ /// reached.
146+ pub async fn send_request (
147+ & self ,
148+ message : Bytes ,
149+ ) -> Result < oneshot:: Receiver < Result < Bytes , ReqError > > , ReqError > {
143150 let ( response_tx, response_rx) = oneshot:: channel ( ) ;
144151
145152 let msg = ReqMessage :: new ( message) ;
@@ -153,7 +160,13 @@ where
153160 TrySendError :: Closed ( _) => ReqError :: SocketClosed ,
154161 } ) ?;
155162
156- response_rx. await . map_err ( |_| ReqError :: SocketClosed ) ?
163+ Ok ( response_rx)
164+ }
165+
166+ /// Send a request and await for the response.
167+ pub async fn request ( & self , message : Bytes ) -> Result < Bytes , ReqError > {
168+ let rx = self . send_request ( message) . await ?;
169+ rx. await . map_err ( |_| ReqError :: SocketClosed ) ?
157170 }
158171
159172 /// Tries to connect to the target endpoint with the default options.
You can’t perform that action at this time.
0 commit comments