@@ -10,6 +10,18 @@ use aws_sdk_lambda::primitives::SdkBody;
1010use aws_sdk_lambda:: { meta:: PKG_VERSION , Client } ;
1111use aws_smithy_async:: time:: TimeSource ;
1212use aws_smithy_http:: result:: ConnectorError ;
13+ use aws_smithy_runtime_api:: {
14+ client:: {
15+ http:: {
16+ HttpClient , HttpConnector , HttpConnectorFuture , HttpConnectorSettings ,
17+ SharedHttpConnector ,
18+ } ,
19+ orchestrator:: HttpRequest ,
20+ runtime_components:: RuntimeComponents ,
21+ } ,
22+ shared:: IntoShared ,
23+ } ;
24+
1325use serde:: Deserialize ;
1426use std:: time:: SystemTime ;
1527use wasm_bindgen:: { prelude:: * , JsCast } ;
@@ -63,7 +75,7 @@ pub async fn main(region: String, verbose: bool) -> Result<String, String> {
6375 . region ( Region :: new ( region) )
6476 . time_source ( BrowserNow )
6577 . credentials_provider ( credentials_provider)
66- . http_connector ( Adapter :: new ( verbose, access_key == "access_key" ) )
78+ . http_client ( Adapter :: new ( verbose, access_key == "access_key" ) )
6779 . load ( )
6880 . await ;
6981 tracing:: info!( "sdk config: {:#?}" , shared_config) ;
@@ -234,24 +246,8 @@ impl Adapter {
234246 }
235247}
236248
237- impl tower:: Service < http:: Request < SdkBody > > for Adapter {
238- type Response = http:: Response < SdkBody > ;
239-
240- type Error = ConnectorError ;
241-
242- #[ allow( clippy:: type_complexity) ]
243- type Future = std:: pin:: Pin <
244- Box < dyn std:: future:: Future < Output = Result < Self :: Response , Self :: Error > > + Send + ' static > ,
245- > ;
246-
247- fn poll_ready (
248- & mut self ,
249- _cx : & mut std:: task:: Context < ' _ > ,
250- ) -> std:: task:: Poll < Result < ( ) , Self :: Error > > {
251- std:: task:: Poll :: Ready ( Ok ( ( ) ) )
252- }
253-
254- fn call ( & mut self , req : http:: Request < SdkBody > ) -> Self :: Future {
249+ impl HttpConnector for Adapter {
250+ fn call ( & self , req : HttpRequest ) -> HttpConnectorFuture {
255251 let ( parts, body) = req. into_parts ( ) ;
256252 let uri = parts. uri . to_string ( ) ;
257253 if self . verbose {
@@ -277,10 +273,20 @@ impl tower::Service<http::Request<SdkBody>> for Adapter {
277273 ) ;
278274 } ) ;
279275
280- Box :: pin ( async move {
276+ HttpConnectorFuture :: new ( async move {
281277 let response = rx. await . map_err ( |e| ConnectorError :: user ( Box :: new ( e) ) ) ?;
282278 log ! ( "response received" ) ;
283279 Ok ( response)
284280 } )
285281 }
286282}
283+
284+ impl HttpClient for Adapter {
285+ fn http_connector (
286+ & self ,
287+ _settings : & HttpConnectorSettings ,
288+ _components : & RuntimeComponents ,
289+ ) -> SharedHttpConnector {
290+ self . clone ( ) . into_shared ( )
291+ }
292+ }
0 commit comments