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

Minimum throughput body timeouts Pt.1 #3068

Merged
merged 21 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aws/sdk/integration-tests/s3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ futures-util = { version = "0.3.16", default-features = false }
hdrhistogram = "7.5.2"
http = "0.2.3"
http-body = "0.4.5"
hyper = "0.14.26"
hyper = { version = "0.14.26", features = ["stream"] }
once_cell = "1.18.0"
pretty_assertions = "1.3"
serde_json = "1"
smol = "1.2"
Expand Down
2 changes: 0 additions & 2 deletions rust-runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[workspace]


members = [
"inlineable",
"aws-smithy-async",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ mod test {
// `tokio_test::task::Spawn::poll_next` can only be invoked when the wrapped
// type implements the `Stream` trait. Here, `FnStream` does not implement it,
// so we work around it by using the `enter` method.
let _ = test_stream.enter(|ctx, pin| {
test_stream.enter(|ctx, pin| {
let polled = pin.poll_next(ctx);
assert!(polled.is_pending());
});
let _ = test_stream.enter(|ctx, pin| {
test_stream.enter(|ctx, pin| {
let polled = pin.poll_next(ctx);
assert!(polled.is_pending());
});
Expand Down
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-async/src/rt/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn default_async_sleep() -> Option<SharedAsyncSleep> {
/// Future returned by [`AsyncSleep`].
#[non_exhaustive]
#[must_use]
pub struct Sleep(Pin<Box<dyn Future<Output = ()> + Send + 'static>>);
pub struct Sleep(Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Futures shouldn't be Sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking with Carl, I decided that this future should in fact be sync. While we could wrap this future in a mutex or similar to make it Sync, I'm opting to just add the bound. The reasoning is that omitting the Sync bound will cause more user pain than including it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requiring a future to be Sync can cause some issue when used with an async block (lang forum), but I don't necessarily see how that bites us here 🤔

At least, I think this PR needs a label breaking-change because Sleep::new now fails to take an async block for certain cases (playground - derived from the above lang forum).


impl Debug for Sleep {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Expand All @@ -95,7 +95,7 @@ impl Sleep {
/// Create a new [`Sleep`] future
///
/// The provided future will be Boxed.
pub fn new(future: impl Future<Output = ()> + Send + 'static) -> Sleep {
pub fn new(future: impl Future<Output = ()> + Send + Sync + 'static) -> Sleep {
Sleep(Box::pin(future))
}
}
Expand Down
4 changes: 3 additions & 1 deletion rust-runtime/aws-smithy-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository = "https://github.com/awslabs/smithy-rs"
[features]
client = ["aws-smithy-runtime-api/client"]
http-auth = ["aws-smithy-runtime-api/http-auth"]
connector-hyper-0-14-x = ["dep:hyper", "hyper?/client", "hyper?/http2", "hyper?/http1", "hyper?/tcp"]
connector-hyper-0-14-x = ["dep:hyper", "hyper?/client", "hyper?/http2", "hyper?/http1", "hyper?/tcp", "hyper?/stream"]
tls-rustls = ["dep:hyper-rustls", "dep:rustls", "connector-hyper-0-14-x"]
rt-tokio = ["tokio/rt"]

Expand Down Expand Up @@ -47,6 +47,8 @@ approx = "0.5.1"
aws-smithy-async = { path = "../aws-smithy-async", features = ["rt-tokio", "test-util"] }
aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api", features = ["test-util"] }
aws-smithy-types = { path = "../aws-smithy-types", features = ["test-util"] }
futures-util = "0.3.28"
pretty_assertions = "1.4.0"
tokio = { version = "1.25", features = ["macros", "rt", "rt-multi-thread", "test-util"] }
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
tracing-test = "0.2.1"
Expand Down
3 changes: 3 additions & 0 deletions rust-runtime/aws-smithy-runtime/src/client/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ pub mod test_util;
/// needing to provide equivalent functionality for hyper 1.x in the future.
#[cfg(feature = "connector-hyper-0-14-x")]
pub mod hyper_014;

/// HTTP body and body-wrapper types
pub mod body;
6 changes: 6 additions & 0 deletions rust-runtime/aws-smithy-runtime/src/client/http/body.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

pub mod minimum_throughput;
Loading