@@ -9,11 +9,15 @@ use std::{
9
9
pin:: Pin ,
10
10
str,
11
11
sync:: { Arc , Mutex , Once } ,
12
+ task:: { Context , Poll } ,
12
13
thread,
13
14
} ;
14
15
15
16
use futures:: { channel:: oneshot, future, prelude:: * } ;
16
- use tokio:: { net:: TcpListener , runtime:: current_thread:: Runtime } ;
17
+ use tokio:: {
18
+ net:: { TcpListener , TcpStream } ,
19
+ runtime:: current_thread:: Runtime ,
20
+ } ;
17
21
18
22
// A "bomb" so when the test task exists we know when to shut down
19
23
// the server and fail if the subtask failed.
@@ -149,14 +153,17 @@ struct Proxy {
149
153
client : Option < Client > ,
150
154
}
151
155
152
- impl hyper:: service:: Service for Proxy {
153
- type ReqBody = hyper:: Body ;
154
- type ResBody = hyper:: Body ;
156
+ impl tower_service:: Service < hyper:: Request < hyper:: Body > > for Proxy {
157
+ type Response = hyper:: Response < hyper:: Body > ;
155
158
type Error = hyper:: Error ;
156
159
type Future =
157
160
Pin < Box < dyn Future < Output = Result < hyper:: Response < hyper:: Body > , hyper:: Error > > + Send > > ;
158
161
159
- fn call ( & mut self , req : hyper:: Request < Self :: ReqBody > ) -> Self :: Future {
162
+ fn poll_ready ( & mut self , _: & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
163
+ Poll :: Ready ( Ok ( ( ) ) )
164
+ }
165
+
166
+ fn call ( & mut self , req : hyper:: Request < hyper:: Body > ) -> Self :: Future {
160
167
match * self . record . lock ( ) . unwrap ( ) {
161
168
Record :: Capture ( _, _) => {
162
169
let client = self . client . as_ref ( ) . unwrap ( ) . clone ( ) ;
@@ -176,15 +183,16 @@ impl hyper::service::Service for Proxy {
176
183
}
177
184
}
178
185
179
- impl < Target > hyper:: service:: MakeService < Target > for Proxy {
180
- type ReqBody = hyper:: Body ;
181
- type ResBody = hyper:: Body ;
186
+ impl < ' a > tower_service:: Service < & ' a TcpStream > for Proxy {
187
+ type Response = Proxy ;
182
188
type Error = hyper:: Error ;
183
- type Service = Proxy ;
184
189
type Future = Pin < Box < dyn Future < Output = Result < Proxy , hyper:: Error > > + Send + ' static > > ;
185
- type MakeError = hyper:: Error ;
186
190
187
- fn make_service ( & mut self , _: Target ) -> Self :: Future {
191
+ fn poll_ready ( & mut self , _: & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
192
+ Poll :: Ready ( Ok ( ( ) ) )
193
+ }
194
+
195
+ fn call ( & mut self , _: & ' a TcpStream ) -> Self :: Future {
188
196
Box :: pin ( future:: ok ( self . clone ( ) ) )
189
197
}
190
198
}
0 commit comments