Unverified Commit 768237a5 authored by Zelda Hessler's avatar Zelda Hessler Committed by GitHub
Browse files

Feature: Stalled stream protection (#3202)

[See the upgrade guide for this feature to learn
more.](https://github.com/awslabs/aws-sdk-rust/discussions/956)

The breaking change is to the `MinimumThroughputBody::new` method.

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
#1562

## Description
<!--- Describe your changes in detail -->
https://github.com/awslabs/aws-sdk-rust/discussions/956



## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
I added several tests

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
parent ad520b08
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -11,6 +11,44 @@
# meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"}
# author = "rcoh"

[[aws-sdk-rust]]
message = """
Add configurable stalled-stream protection for downloads.

When making HTTP calls,
it's possible for a connection to 'stall out' and emit no more data due to server-side issues.
In the event this happens, it's desirable for the stream to error out as quickly as possible.
While timeouts can protect you from this issue, they aren't adaptive to the amount of data
being sent and so must be configured specifically for each use case. When enabled, stalled-stream
protection will ensure that bad streams error out quickly, regardless of the amount of data being
downloaded.

Protection is enabled by default for all clients but can be configured or disabled.
See [this discussion](https://github.com/awslabs/aws-sdk-rust/discussions/956) for more details.
"""
references = ["smithy-rs#3202"]
meta = { "breaking" = true, "tada" = true, "bug" = false }
author = "Velfi"

[[smithy-rs]]
message = """
Add configurable stalled-stream protection for downloads.

When making HTTP calls,
it's possible for a connection to 'stall out' and emit no more data due to server-side issues.
In the event this happens, it's desirable for the stream to error out as quickly as possible.
While timeouts can protect you from this issue, they aren't adaptive to the amount of data
being sent and so must be configured specifically for each use case. When enabled, stalled-stream
protection will ensure that bad streams error out quickly, regardless of the amount of data being
downloaded.

Protection is enabled by default for all clients but can be configured or disabled.
See [this discussion](https://github.com/awslabs/aws-sdk-rust/discussions/956) for more details.
"""
references = ["smithy-rs#3202"]
meta = { "breaking" = true, "tada" = true, "bug" = false, "target" = "client" }
author = "Velfi"

[[aws-sdk-rust]]
message = "Make certain types for EMR Serverless optional. Previously, they defaulted to 0, but this created invalid requests."
references = ["smithy-rs#3217"]
+2 −1
Original line number Diff line number Diff line
@@ -14,15 +14,16 @@ allowed_external_types = [
   "aws_smithy_runtime_api::box_error::BoxError",
   "aws_smithy_runtime::client::identity::cache::IdentityCache",
   "aws_smithy_runtime::client::identity::cache::lazy::LazyCacheBuilder",
   "aws_smithy_runtime_api::client::behavior_version::BehaviorVersion",
   "aws_smithy_runtime_api::client::dns::ResolveDns",
   "aws_smithy_runtime_api::client::dns::SharedDnsResolver",
   "aws_smithy_runtime_api::client::http::HttpClient",
   "aws_smithy_runtime_api::client::http::SharedHttpClient",
   "aws_smithy_runtime_api::client::identity::ResolveCachedIdentity",
   "aws_smithy_runtime_api::client::identity::ResolveIdentity",
   "aws_smithy_runtime_api::client::behavior_version::BehaviorVersion",
   "aws_smithy_runtime_api::client::orchestrator::HttpResponse",
   "aws_smithy_runtime_api::client::result::SdkError",
   "aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig",
   "aws_smithy_types::body::SdkBody",
   "aws_smithy_types::retry",
   "aws_smithy_types::retry::*",
+37 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ pub mod retry;
mod sensitive_command;
#[cfg(feature = "sso")]
pub mod sso;
pub mod stalled_stream_protection;
pub(crate) mod standard_property;
pub mod sts;
pub mod timeout;
@@ -216,6 +217,7 @@ mod loader {
    use aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
    use aws_smithy_runtime_api::client::http::HttpClient;
    use aws_smithy_runtime_api::client::identity::{ResolveCachedIdentity, SharedIdentityCache};
    use aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
    use aws_smithy_runtime_api::shared::IntoShared;
    use aws_smithy_types::retry::RetryConfig;
    use aws_smithy_types::timeout::TimeoutConfig;
@@ -259,6 +261,7 @@ mod loader {
        use_fips: Option<bool>,
        use_dual_stack: Option<bool>,
        time_source: Option<SharedTimeSource>,
        stalled_stream_protection_config: Option<StalledStreamProtectionConfig>,
        env: Option<Env>,
        fs: Option<Fs>,
        behavior_version: Option<BehaviorVersion>,
@@ -611,6 +614,39 @@ mod loader {
            self
        }

        /// Override the [`StalledStreamProtectionConfig`] used to build [`SdkConfig`](aws_types::SdkConfig).
        ///
        /// This configures stalled stream protection. When enabled, download streams
        /// that stop (stream no data) for longer than a configured grace period will return an error.
        ///
        /// By default, streams that transmit less than one byte per-second for five seconds will
        /// be cancelled.
        ///
        /// _Note_: When an override is provided, the default implementation is replaced.
        ///
        /// # Examples
        /// ```no_run
        /// # async fn create_config() {
        /// use aws_config::stalled_stream_protection::StalledStreamProtectionConfig;
        /// use std::time::Duration;
        /// let config = aws_config::from_env()
        ///     .stalled_stream_protection(
        ///         StalledStreamProtectionConfig::enabled()
        ///             .grace_period(Duration::from_secs(1))
        ///             .build()
        ///     )
        ///     .load()
        ///     .await;
        /// # }
        /// ```
        pub fn stalled_stream_protection(
            mut self,
            stalled_stream_protection_config: StalledStreamProtectionConfig,
        ) -> Self {
            self.stalled_stream_protection_config = Some(stalled_stream_protection_config);
            self
        }

        /// Set configuration for all sub-loaders (credentials, region etc.)
        ///
        /// Update the `ProviderConfig` used for all nested loaders. This can be used to override
@@ -757,6 +793,7 @@ mod loader {
            builder.set_endpoint_url(self.endpoint_url);
            builder.set_use_fips(use_fips);
            builder.set_use_dual_stack(use_dual_stack);
            builder.set_stalled_stream_protection(self.stalled_stream_protection_config);
            builder.build()
        }
    }
+9 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

//! Stalled stream protection configuration

// Re-export from aws-smithy-types
pub use aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
+2 −1
Original line number Diff line number Diff line
@@ -5,11 +5,12 @@ allowed_external_types = [
    "aws_smithy_async::rt::sleep::SharedAsyncSleep",
    "aws_smithy_async::time::SharedTimeSource",
    "aws_smithy_async::time::TimeSource",
    "aws_smithy_runtime_api::client::behavior_version::BehaviorVersion",
    "aws_smithy_runtime_api::client::http::HttpClient",
    "aws_smithy_runtime_api::client::http::SharedHttpClient",
    "aws_smithy_runtime_api::client::identity::ResolveCachedIdentity",
    "aws_smithy_runtime_api::client::identity::SharedIdentityCache",
    "aws_smithy_runtime_api::client::behavior_version::BehaviorVersion",
    "aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig",
    "aws_smithy_runtime_api::http::headers::Headers",
    "aws_smithy_types::config_bag::storable::Storable",
    "aws_smithy_types::config_bag::storable::StoreReplace",
Loading