Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move result and connection from aws-smithy-http to aws-smithy-types #3093

8 changes: 8 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,11 @@ message = "`ByteStream::poll_next` is now feature-gated. You can turn on a cargo
references = ["smithy-rs#3033", "smithy-rs#3088"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all" }
author = "ysaito1001"

[[smithy-rs]]
message = """
The [`connection`](https://docs.rs/aws-smithy-http/latest/aws_smithy_http/connection/index.html) and [`result`](https://docs.rs/aws-smithy-http/latest/aws_smithy_http/result/index.html) modules in `aws-smithy-http` have been moved to `aws_smithy_types`. Type aliases for all affected pub items, except for a trait, are left in `aws_smithy_http` for backwards compatibility but are deprecated. Due to lack of trait aliases, the moved trait `CreateUnhandledError` needs to be used from `aws-smithy-types`.
"""
references = ["smithy-rs#3092", "smithy-rs#3093"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
author = "ysaito1001"
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-config/external-types.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ allowed_external_types = [
"aws_smithy_async::time::TimeSource",
"aws_smithy_http::endpoint",
"aws_smithy_http::endpoint::error::InvalidEndpointError",
"aws_smithy_http::result::SdkError",
"aws_smithy_types::result::SdkError",
"aws_smithy_runtime::client::identity::cache::IdentityCache",
"aws_smithy_runtime::client::identity::cache::lazy::LazyCacheBuilder",
"aws_smithy_runtime_api::client::dns::ResolveDns",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::json_credentials::{parse_json_credentials, JsonCredentials, Refreshab
use crate::provider_config::ProviderConfig;
use aws_credential_types::provider::{self, error::CredentialsError};
use aws_credential_types::Credentials;
use aws_smithy_http::result::SdkError;
use aws_smithy_runtime::client::orchestrator::operation::Operation;
use aws_smithy_runtime::client::retries::classifiers::{
HttpStatusCodeClassifier, TransientErrorClassifier,
Expand All @@ -27,6 +26,7 @@ use aws_smithy_runtime_api::client::retries::classifiers::RetryAction;
use aws_smithy_runtime_api::client::runtime_plugin::StaticRuntimePlugin;
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::config_bag::Layer;
use aws_smithy_types::result::SdkError;
use aws_smithy_types::retry::RetryConfig;
use aws_smithy_types::timeout::TimeoutConfig;
use http::header::{ACCEPT, AUTHORIZATION};
Expand Down
6 changes: 3 additions & 3 deletions aws/rust-runtime/aws-config/src/imds/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use crate::provider_config::ProviderConfig;
use crate::PKG_VERSION;
use aws_http::user_agent::{ApiMetadata, AwsUserAgent};
use aws_runtime::user_agent::UserAgentInterceptor;
use aws_smithy_http::result::ConnectorError;
use aws_smithy_http::result::SdkError;
use aws_smithy_runtime::client::orchestrator::operation::Operation;
use aws_smithy_runtime::client::retries::strategy::StandardRetryStrategy;
use aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams;
Expand All @@ -33,6 +31,8 @@ use aws_smithy_runtime_api::client::runtime_plugin::{RuntimePlugin, SharedRuntim
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::config_bag::{FrozenLayer, Layer};
use aws_smithy_types::endpoint::Endpoint;
use aws_smithy_types::result::ConnectorError;
use aws_smithy_types::result::SdkError;
use aws_smithy_types::retry::RetryConfig;
use aws_smithy_types::timeout::TimeoutConfig;
use aws_types::os_shim_internal::Env;
Expand Down Expand Up @@ -582,7 +582,6 @@ pub(crate) mod test {
use crate::provider_config::ProviderConfig;
use aws_smithy_async::rt::sleep::TokioSleep;
use aws_smithy_async::test_util::{instant_time_and_sleep, InstantSleep};
use aws_smithy_http::result::ConnectorError;
use aws_smithy_runtime::client::http::test_util::{
capture_request, ReplayEvent, StaticReplayClient,
};
Expand All @@ -596,6 +595,7 @@ pub(crate) mod test {
use aws_smithy_runtime_api::client::retries::classifiers::{ClassifyRetry, RetryAction};
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::error::display::DisplayErrorContext;
use aws_smithy_types::result::ConnectorError;
use aws_types::os_shim_internal::{Env, Fs};
use http::header::USER_AGENT;
use http::Uri;
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-config/src/imds/client/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//! Error types for [`ImdsClient`](crate::imds::client::Client)

use aws_smithy_http::endpoint::error::InvalidEndpointError;
use aws_smithy_http::result::SdkError;
use aws_smithy_runtime_api::client::orchestrator::HttpResponse;
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::result::SdkError;
use std::error::Error;
use std::fmt;

Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-config/src/sts/assume_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use aws_sdk_sts::operation::assume_role::builders::AssumeRoleFluentBuilder;
use aws_sdk_sts::operation::assume_role::AssumeRoleError;
use aws_sdk_sts::types::PolicyDescriptorType;
use aws_sdk_sts::Client as StsClient;
use aws_smithy_http::result::SdkError;
use aws_smithy_runtime::client::identity::IdentityCache;
use aws_smithy_types::error::display::DisplayErrorContext;
use aws_smithy_types::result::SdkError;
use aws_types::region::Region;
use aws_types::SdkConfig;
use std::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-http/src/request_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/

use aws_smithy_http::http::HttpHeaders;
use aws_smithy_http::result::SdkError;
use aws_smithy_types::error::metadata::{
Builder as ErrorMetadataBuilder, ErrorMetadata, ProvideErrorMetadata,
};
use aws_smithy_types::error::Unhandled;
use aws_smithy_types::result::SdkError;
use http::{HeaderMap, HeaderValue};

/// Constant for the [`ErrorMetadata`] extra field that contains the request ID
Expand Down
4 changes: 2 additions & 2 deletions aws/rust-runtime/aws-inlineable/src/s3_request_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/

use aws_smithy_http::http::HttpHeaders;
use aws_smithy_http::result::SdkError;
use aws_smithy_types::error::metadata::{
Builder as ErrorMetadataBuilder, ErrorMetadata, ProvideErrorMetadata,
};
use aws_smithy_types::error::Unhandled;
use aws_smithy_types::result::SdkError;
use http::{HeaderMap, HeaderValue};

const EXTENDED_REQUEST_ID: &str = "s3_extended_request_id";
Expand Down Expand Up @@ -94,8 +94,8 @@ fn extract_extended_request_id(headers: &HeaderMap<HeaderValue>) -> Option<&str>
#[cfg(test)]
mod test {
use super::*;
use aws_smithy_http::result::SdkError;
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::result::SdkError;
use http::Response;

#[test]
Expand Down
1 change: 0 additions & 1 deletion aws/rust-runtime/aws-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ aws-smithy-async = { path = "../../../rust-runtime/aws-smithy-async" }
aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types" }
aws-smithy-runtime = { path = "../../../rust-runtime/aws-smithy-runtime", optional = true }
aws-smithy-runtime-api = { path = "../../../rust-runtime/aws-smithy-runtime-api", features = ["client"] }
aws-smithy-http = { path = "../../../rust-runtime/aws-smithy-http" }
tracing = "0.1"
http = "0.2.6"
# cargo does not support optional test dependencies, so to completely disable rustls
Expand Down
2 changes: 1 addition & 1 deletion aws/sdk/integration-tests/kms/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

use aws_sdk_kms as kms;
use aws_sdk_kms::operation::RequestId;
use aws_smithy_http::result::SdkError;
use aws_smithy_runtime::client::http::test_util::{ReplayEvent, StaticReplayClient};
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::result::SdkError;
use http::header::AUTHORIZATION;
use http::Uri;
use kms::config::{Config, Credentials, Region};
Expand Down
2 changes: 1 addition & 1 deletion aws/sdk/integration-tests/kms/tests/retryable_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
use aws_credential_types::Credentials;
use aws_runtime::retries::classifiers::AwsErrorCodeClassifier;
use aws_sdk_kms as kms;
use aws_smithy_http::result::SdkError;
use aws_smithy_runtime::client::http::test_util::infallible_client_fn;
use aws_smithy_runtime_api::client::interceptors::context::{Error, Input, InterceptorContext};
use aws_smithy_runtime_api::client::orchestrator::{HttpResponse, OrchestratorError};
use aws_smithy_runtime_api::client::retries::classifiers::{ClassifyRetry, RetryAction};
use aws_smithy_types::result::SdkError;
use bytes::Bytes;
use kms::operation::create_alias::CreateAliasError;

Expand Down
4 changes: 3 additions & 1 deletion aws/sdk/integration-tests/kms/tests/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ fn assert_debug<T: std::fmt::Debug>() {}
#[tokio::test]
async fn types_are_send_sync() {
assert_send_sync::<kms::Error>();
assert_send_sync::<kms::error::SdkError<CreateAliasError>>();
assert_send_sync::<
kms::error::SdkError<CreateAliasError, http::Response<aws_smithy_types::body::SdkBody>>,
>();
assert_send_sync::<kms::operation::create_alias::CreateAliasError>();
assert_send_sync::<kms::operation::create_alias::CreateAliasOutput>();
assert_send_sync::<kms::Client>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use aws_sdk_s3::types::{
use aws_sdk_s3::{Client, Config};
use aws_smithy_async::assert_elapsed;
use aws_smithy_async::rt::sleep::{AsyncSleep, SharedAsyncSleep, Sleep};
use aws_smithy_http::result::SdkError;
use aws_smithy_runtime::client::http::test_util::NeverClient;
use aws_smithy_runtime::test_util::capture_test_logs::capture_test_logs;
use aws_smithy_types::error::display::DisplayErrorContext;
use aws_smithy_types::result::SdkError;
use aws_smithy_types::timeout::TimeoutConfig;
use std::fmt::Debug;
use std::time::{Duration, Instant};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async fn test_s3_signer_query_string_with_all_valid_chars() {
#[ignore]
async fn test_query_strings_are_correctly_encoded() {
use aws_sdk_s3::operation::list_objects_v2::ListObjectsV2Error;
use aws_smithy_http::result::SdkError;
use aws_smithy_types::result::SdkError;

tracing_subscriber::fmt::init();
let config = aws_config::load_from_env().await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use aws_credential_types::provider::SharedCredentialsProvider;
use aws_credential_types::Credentials;
use aws_smithy_async::rt::sleep::{SharedAsyncSleep, TokioSleep};
use aws_smithy_http::result::SdkError;
use aws_smithy_types::result::SdkError;
use aws_smithy_types::timeout::TimeoutConfig;
use aws_types::region::Region;
use aws_types::SdkConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ class FluentClientGenerator(
"OperationError" to errorType,
"OperationOutput" to outputType,
"SdkError" to RuntimeType.sdkError(runtimeConfig),
"SdkSuccess" to RuntimeType.sdkSuccess(runtimeConfig),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class OperationErrorGenerator(
private val runtimeConfig = symbolProvider.config.runtimeConfig
private val errorMetadata = errorMetadata(symbolProvider.config.runtimeConfig)
private val createUnhandledError =
RuntimeType.smithyHttp(runtimeConfig).resolve("result::CreateUnhandledError")
RuntimeType.smithyTypes(runtimeConfig).resolve("result::CreateUnhandledError")

private fun operationErrors(): List<StructureShape> =
(operationOrEventStream as OperationShape).operationErrors(model).map { it.asStructureShape().get() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,7 @@ data class RuntimeType(val path: String, val dependency: RustDependency? = null)

fun queryFormat(runtimeConfig: RuntimeConfig, func: String) = smithyHttp(runtimeConfig).resolve("query::$func")
fun sdkBody(runtimeConfig: RuntimeConfig): RuntimeType = smithyTypes(runtimeConfig).resolve("body::SdkBody")
fun sdkError(runtimeConfig: RuntimeConfig): RuntimeType = smithyHttp(runtimeConfig).resolve("result::SdkError")
fun sdkSuccess(runtimeConfig: RuntimeConfig): RuntimeType =
smithyHttp(runtimeConfig).resolve("result::SdkSuccess")
fun sdkError(runtimeConfig: RuntimeConfig): RuntimeType = smithyTypes(runtimeConfig).resolve("result::SdkError")

fun parseTimestampFormat(
codegenTarget: CodegenTarget,
Expand Down
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-http/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

//TODO(runtimeCratesVersioningCleanup): Re-point those who use the deprecated type aliases to
// directly depend on `aws_smithy_types` and remove this module.
//TODO(runtimeCratesVersioningCleanup): Keep the following deprecated type aliases for at least
// one release since 0.56.1 and then remove this module.

//! Types for representing the body of an HTTP request or response

Expand Down
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-http/src/byte_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

//TODO(runtimeCratesVersioningCleanup): Re-point those who use the deprecated type aliases to
// directly depend on `aws_smithy_types` and remove this module.
//TODO(runtimeCratesVersioningCleanup): Keep the following deprecated type aliases for at least
// one release since 0.56.1 and then remove this module.

//! ByteStream Abstractions

Expand Down
50 changes: 5 additions & 45 deletions rust-runtime/aws-smithy-http/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

//! Types related to connection monitoring and management.
//TODO(runtimeCratesVersioningCleanup): Keep the following deprecated type alias for at least
// one release since 0.56.1 and then remove this module.

use std::fmt::{Debug, Formatter};
use std::net::SocketAddr;
use std::sync::Arc;
//! Types related to connection monitoring and management.

/// Metadata that tracks the state of an active connection.
#[derive(Clone)]
pub struct ConnectionMetadata {
is_proxied: bool,
remote_addr: Option<SocketAddr>,
poison_fn: Arc<dyn Fn() + Send + Sync>,
}

impl ConnectionMetadata {
/// Poison this connection, ensuring that it won't be reused.
pub fn poison(&self) {
tracing::info!("smithy connection was poisoned");
(self.poison_fn)()
}

/// Create a new [`ConnectionMetadata`].
pub fn new(
is_proxied: bool,
remote_addr: Option<SocketAddr>,
poison: impl Fn() + Send + Sync + 'static,
) -> Self {
Self {
is_proxied,
remote_addr,
poison_fn: Arc::new(poison),
}
}

/// Get the remote address for this connection, if one is set.
pub fn remote_addr(&self) -> Option<SocketAddr> {
self.remote_addr
}
}

impl Debug for ConnectionMetadata {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SmithyConnection")
.field("is_proxied", &self.is_proxied)
.field("remote_addr", &self.remote_addr)
.finish()
}
}
#[deprecated(note = "Moved to `aws_smithy_types::connection::ConnectionMetadata`.")]
pub type ConnectionMetadata = aws_smithy_types::connection::ConnectionMetadata;
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-http/src/event_stream/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

use crate::result::{ConnectorError, SdkError};
use aws_smithy_eventstream::frame::{
DecodedFrame, Message, MessageFrameDecoder, UnmarshallMessage, UnmarshalledMessage,
};
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::result::{ConnectorError, SdkError};
use bytes::Buf;
use bytes::Bytes;
use bytes_utils::SegmentedBuf;
Expand Down Expand Up @@ -276,10 +276,10 @@ impl<T, E> Receiver<T, E> {
#[cfg(test)]
mod tests {
use super::{Receiver, UnmarshallMessage};
use crate::result::SdkError;
use aws_smithy_eventstream::error::Error as EventStreamError;
use aws_smithy_eventstream::frame::{Header, HeaderValue, Message, UnmarshalledMessage};
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::result::SdkError;
use bytes::Bytes;
use hyper::body::Body;
use std::error::Error as StdError;
Expand Down
7 changes: 4 additions & 3 deletions rust-runtime/aws-smithy-http/src/event_stream/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

use crate::result::SdkError;
use aws_smithy_eventstream::frame::{MarshallMessage, SignMessage};
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::result::SdkError;
use bytes::Bytes;
use futures_core::Stream;
use std::error::Error as StdError;
Expand Down Expand Up @@ -140,7 +141,7 @@ impl<T, E: StdError + Send + Sync + 'static> MessageStreamAdapter<T, E> {
}

impl<T, E: StdError + Send + Sync + 'static> Stream for MessageStreamAdapter<T, E> {
type Item = Result<Bytes, SdkError<E>>;
type Item = Result<Bytes, SdkError<E, http::Response<SdkBody>>>;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
match self.stream.as_mut().poll_next(cx) {
Expand Down Expand Up @@ -195,12 +196,12 @@ impl<T, E: StdError + Send + Sync + 'static> Stream for MessageStreamAdapter<T,
mod tests {
use super::MarshallMessage;
use crate::event_stream::{EventStreamSender, MessageStreamAdapter};
use crate::result::SdkError;
use async_stream::stream;
use aws_smithy_eventstream::error::Error as EventStreamError;
use aws_smithy_eventstream::frame::{
Header, HeaderValue, Message, NoOpSigner, SignMessage, SignMessageError,
};
use aws_smithy_types::result::SdkError;
use bytes::Bytes;
use futures_core::Stream;
use futures_util::stream::StreamExt;
Expand Down
Loading
Loading