-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduce overhauled stalled stream protection and upload support
This commit unreverts 27834ae (#3485). Original commit message: Overhaul stalled stream protection and add upload support (#3485) This PR overhauls the existing stalled stream protection with a new algorithm, and also adds support for minimum throughput on upload streams. The new algorithm adds support for differentiating between the user or the server causing the stall, and not timing out if it's the user causing the stall. This will fix timeout issues when a customer makes remote service calls in between streaming pieces of information.
- Loading branch information
Showing
21 changed files
with
2,007 additions
and
601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
//! Body wrappers must pass through size_hint | ||
|
||
use aws_config::SdkConfig; | ||
use aws_sdk_s3::{ | ||
config::{Credentials, Region, SharedCredentialsProvider}, | ||
primitives::{ByteStream, SdkBody}, | ||
Client, | ||
}; | ||
use aws_smithy_runtime::client::http::test_util::{capture_request, infallible_client_fn}; | ||
use http_body::Body; | ||
|
||
#[tokio::test] | ||
async fn download_body_size_hint_check() { | ||
let test_body_content = b"hello"; | ||
let test_body = || SdkBody::from(&test_body_content[..]); | ||
assert_eq!( | ||
Some(test_body_content.len() as u64), | ||
(test_body)().size_hint().exact(), | ||
"pre-condition check" | ||
); | ||
|
||
let http_client = infallible_client_fn(move |_| { | ||
http::Response::builder() | ||
.status(200) | ||
.body((test_body)()) | ||
.unwrap() | ||
}); | ||
let sdk_config = SdkConfig::builder() | ||
.credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) | ||
.region(Region::new("us-east-1")) | ||
.http_client(http_client) | ||
.build(); | ||
let client = Client::new(&sdk_config); | ||
let response = client | ||
.get_object() | ||
.bucket("foo") | ||
.key("foo") | ||
.send() | ||
.await | ||
.unwrap(); | ||
assert_eq!( | ||
( | ||
test_body_content.len() as u64, | ||
Some(test_body_content.len() as u64), | ||
), | ||
response.body.size_hint(), | ||
"the size hint should be passed through all the default body wrappers" | ||
); | ||
} | ||
|
||
#[tokio::test] | ||
async fn upload_body_size_hint_check() { | ||
let test_body_content = b"hello"; | ||
|
||
let (http_client, rx) = capture_request(None); | ||
let sdk_config = SdkConfig::builder() | ||
.credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) | ||
.region(Region::new("us-east-1")) | ||
.http_client(http_client) | ||
.build(); | ||
let client = Client::new(&sdk_config); | ||
let body = ByteStream::from_static(test_body_content); | ||
assert_eq!( | ||
( | ||
test_body_content.len() as u64, | ||
Some(test_body_content.len() as u64), | ||
), | ||
body.size_hint(), | ||
"pre-condition check" | ||
); | ||
let _response = client | ||
.put_object() | ||
.bucket("foo") | ||
.key("foo") | ||
.body(body) | ||
.send() | ||
.await; | ||
let captured_request = rx.expect_request(); | ||
assert_eq!( | ||
Some(test_body_content.len() as u64), | ||
captured_request.body().size_hint().exact(), | ||
"the size hint should be passed through all the default body wrappers" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "aws-smithy-runtime-api" | ||
version = "1.3.0" | ||
version = "1.4.0" | ||
authors = ["AWS Rust SDK Team <[email protected]>", "Zelda Hessler <[email protected]>"] | ||
description = "Smithy runtime types." | ||
edition = "2021" | ||
|
Oops, something went wrong.