Loading CHANGELOG.next.toml +7 −1 Original line number Diff line number Diff line Loading @@ -132,3 +132,9 @@ set (don't emit it for the default paths) references = ["smithy-rs#1558", "aws-sdk-rust#583"] meta = { "breaking" = false, "tada" = false, "bug" = true } author = "jdisanti" [[aws-sdk-rust]] message = "The `imds::Client` in `aws-config` now implements `Clone`" references = ["smithy-rs#1557", "aws-sdk-rust#580"] meta = { "breaking" = false, "tada" = true, "bug" = false } author = "jdisanti" aws/rust-runtime/aws-config/src/imds/client.rs +37 −25 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ use std::convert::TryFrom; use std::error::Error; use std::fmt::{Display, Formatter}; use std::str::FromStr; use std::sync::Arc; use std::time::Duration; use aws_http::user_agent::{ApiMetadata, AwsUserAgent, UserAgentStage}; Loading Loading @@ -124,10 +125,15 @@ fn user_agent() -> AwsUserAgent { /// /// 7. The default value of `http://169.254.169.254` will be used. /// #[derive(Debug)] #[derive(Clone, Debug)] pub struct Client { inner: Arc<ClientInner>, } #[derive(Debug)] struct ClientInner { endpoint: Endpoint, inner: aws_smithy_client::Client<DynConnector, ImdsMiddleware>, smithy_client: aws_smithy_client::Client<DynConnector, ImdsMiddleware>, } /// Client where build is sync, but usage is async Loading Loading @@ -194,7 +200,11 @@ impl Client { /// ``` pub async fn get(&self, path: &str) -> Result<String, ImdsError> { let operation = self.make_operation(path)?; self.inner.call(operation).await.map_err(|err| match err { self.inner .smithy_client .call(operation) .await .map_err(|err| match err { SdkError::ConstructionFailure(err) => match err.downcast::<ImdsError>() { Ok(token_failure) => *token_failure, Err(other) => ImdsError::Unexpected(other), Loading Loading @@ -224,7 +234,7 @@ impl Client { path: &str, ) -> Result<Operation<ImdsGetResponseHandler, ImdsErrorPolicy>, ImdsError> { let mut base_uri: Uri = path.parse().map_err(|_| ImdsError::InvalidPath)?; self.endpoint.set_endpoint(&mut base_uri, None); self.inner.endpoint.set_endpoint(&mut base_uri, None); let request = http::Request::builder() .uri(base_uri) .body(SdkBody::empty()) Loading Loading @@ -568,7 +578,7 @@ impl Builder { config.sleep(), ); let middleware = ImdsMiddleware { token_loader }; let inner_client = aws_smithy_client::Builder::new() let smithy_client = aws_smithy_client::Builder::new() .connector(connector.clone()) .middleware(middleware) .sleep_impl(config.sleep()) Loading @@ -577,8 +587,10 @@ impl Builder { .with_timeout_config(timeout_config); let client = Client { inner: Arc::new(ClientInner { endpoint, inner: inner_client, smithy_client, }), }; Ok(client) } Loading Loading
CHANGELOG.next.toml +7 −1 Original line number Diff line number Diff line Loading @@ -132,3 +132,9 @@ set (don't emit it for the default paths) references = ["smithy-rs#1558", "aws-sdk-rust#583"] meta = { "breaking" = false, "tada" = false, "bug" = true } author = "jdisanti" [[aws-sdk-rust]] message = "The `imds::Client` in `aws-config` now implements `Clone`" references = ["smithy-rs#1557", "aws-sdk-rust#580"] meta = { "breaking" = false, "tada" = true, "bug" = false } author = "jdisanti"
aws/rust-runtime/aws-config/src/imds/client.rs +37 −25 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ use std::convert::TryFrom; use std::error::Error; use std::fmt::{Display, Formatter}; use std::str::FromStr; use std::sync::Arc; use std::time::Duration; use aws_http::user_agent::{ApiMetadata, AwsUserAgent, UserAgentStage}; Loading Loading @@ -124,10 +125,15 @@ fn user_agent() -> AwsUserAgent { /// /// 7. The default value of `http://169.254.169.254` will be used. /// #[derive(Debug)] #[derive(Clone, Debug)] pub struct Client { inner: Arc<ClientInner>, } #[derive(Debug)] struct ClientInner { endpoint: Endpoint, inner: aws_smithy_client::Client<DynConnector, ImdsMiddleware>, smithy_client: aws_smithy_client::Client<DynConnector, ImdsMiddleware>, } /// Client where build is sync, but usage is async Loading Loading @@ -194,7 +200,11 @@ impl Client { /// ``` pub async fn get(&self, path: &str) -> Result<String, ImdsError> { let operation = self.make_operation(path)?; self.inner.call(operation).await.map_err(|err| match err { self.inner .smithy_client .call(operation) .await .map_err(|err| match err { SdkError::ConstructionFailure(err) => match err.downcast::<ImdsError>() { Ok(token_failure) => *token_failure, Err(other) => ImdsError::Unexpected(other), Loading Loading @@ -224,7 +234,7 @@ impl Client { path: &str, ) -> Result<Operation<ImdsGetResponseHandler, ImdsErrorPolicy>, ImdsError> { let mut base_uri: Uri = path.parse().map_err(|_| ImdsError::InvalidPath)?; self.endpoint.set_endpoint(&mut base_uri, None); self.inner.endpoint.set_endpoint(&mut base_uri, None); let request = http::Request::builder() .uri(base_uri) .body(SdkBody::empty()) Loading Loading @@ -568,7 +578,7 @@ impl Builder { config.sleep(), ); let middleware = ImdsMiddleware { token_loader }; let inner_client = aws_smithy_client::Builder::new() let smithy_client = aws_smithy_client::Builder::new() .connector(connector.clone()) .middleware(middleware) .sleep_impl(config.sleep()) Loading @@ -577,8 +587,10 @@ impl Builder { .with_timeout_config(timeout_config); let client = Client { inner: Arc::new(ClientInner { endpoint, inner: inner_client, smithy_client, }), }; Ok(client) } Loading