Skip to content

Commit

Permalink
[autosync] Add default list of http versions to request property bag …
Browse files Browse the repository at this point in the history
…(#1258)

* add: default list of http versions
add: type alias for list of http versions
add: decorator to add desired http versions to property bag
fix: gradle warning for argument "model"
update: CHANGELOG

* fix: clippy lint

* update: use more accurate name for test RustCodegenDecorators
rename: HttpVersionListGenerator.kt to HttpVersionListCustomization.kt
update: HttpVersionListCustomization to grab versions from models when possible
fix: various docs issues reported by IDE
add: new "Extras" section to ServiceConfig
update: code broke by "Extras" change
add: tests for http version sniffing
  • Loading branch information
Velfi authored and jdisanti committed Mar 17, 2022
1 parent 75dfe2b commit 35373cb
Show file tree
Hide file tree
Showing 303 changed files with 33,910 additions and 266 deletions.
2 changes: 1 addition & 1 deletion .smithyrs-githash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
beeca577cb96fe07ece3200059fa1bcb56bfe166
3eaddcf7383b6e2e6a2d23f01e2b372af5e131ff
4 changes: 2 additions & 2 deletions examples/localstack/src/bin/use-localstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ fn localstack_endpoint() -> Endpoint {
Endpoint::immutable(Uri::from_static("http://localhost:4566/"))
}

fn sqs_client(conf: &aws_types::config::Config) -> aws_sdk_sqs::Client {
fn sqs_client(conf: &aws_types::SdkConfig) -> aws_sdk_sqs::Client {
let mut sqs_config_builder = aws_sdk_sqs::config::Builder::from(conf);
if use_localstack() {
sqs_config_builder = sqs_config_builder.endpoint_resolver(localstack_endpoint())
}
aws_sdk_sqs::Client::from_conf(sqs_config_builder.build())
}

fn s3_client(conf: &aws_types::config::Config) -> aws_sdk_s3::Client {
fn s3_client(conf: &aws_types::SdkConfig) -> aws_sdk_s3::Client {
let mut s3_config_builder = aws_sdk_s3::config::Builder::from(conf);
if use_localstack() {
s3_config_builder = s3_config_builder.endpoint_resolver(localstack_endpoint());
Expand Down
4 changes: 4 additions & 0 deletions examples/setting-timeouts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ features = ["rustls"]
path = "../../sdk/aws-smithy-client"
version = "0.38.0"

[dependencies.aws-smithy-types]
path = "../../sdk/aws-smithy-types"
version = "0.38.0"

[dependencies.tokio]
version = "1"
features = ["full"]
Expand Down
62 changes: 40 additions & 22 deletions examples/setting-timeouts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
* SPDX-License-Identifier: Apache-2.0.
*/

use aws_config::TimeoutConfig;
use aws_smithy_client::{conns, erase::DynConnector, hyper_ext};
// Note: `TriState` is used to distinguish between configurations that are
// intentionally set, disabled, or unset.
//
// If you're familiar with languages like SQL or JavaScript, it might be
// helpful to think of the `TriState` definitions as follows:
//
// - `TriState::Set(value)` is a set value
// - `TriState::Disabled` is similar to `null`
// - `TriState::Unset` is similar to `undefined`
//
// With these distinctions, it's less complicated to merge configurations
// from multiple sources. Set or disabled values are kept, while unset values are overwritten.
use aws_smithy_types::{timeout, tristate::TriState};
use std::time::Duration;

/// The SDK divides timeouts into two groups:
Expand Down Expand Up @@ -35,37 +47,43 @@ async fn main() -> Result<(), aws_sdk_s3::Error> {
// Here we create an object that holds timeout-related configuration. We'll have to pass this
// config into two places. This is because different timeouts are handled at different
// "levels" of the AWS SDK Client networking stack. We'll note which timeouts are getting
// set each time we pass in this cofiguration.
let timeout_config = TimeoutConfig::new()
// This timeout acts at the "Request to a service" level. When the SDK makes a request to a
// service, that "request" may actually comprise of several HTTP requests in order to retry
// failures that are likely spurious or to refresh credentials.
.with_api_call_timeout(Some(Duration::from_secs(2)))
// This timeout acts at the "HTTP request" level and will set a separate timeout for each
// HTTP request made as part of a "service request"
.with_api_call_attempt_timeout(Some(Duration::from_secs(2)))
// A limit on the amount of time an application takes to attempt to read the first byte over
// an established, open connection after write request.
// Also known as the "time to first byte" timeout
.with_read_timeout(Some(Duration::from_secs(2)))
// A limit on the amount of time after making an initial connect attempt on a socket to
// complete the connect-handshake
.with_connect_timeout(Some(Duration::from_secs(2)));
// set each time we pass in this configuration.
let timeout_config = timeout::Config::new()
.with_api_timeouts(
timeout::Api::new()
// This timeout acts at the "Request to a service" level. When the SDK makes a request to a
// service, that "request" can contain several HTTP requests. This way, you can retry
// failures that are likely spurious, or refresh credentials.
.with_call_timeout(TriState::Set(Duration::from_secs(2)))
// This timeout acts at the "HTTP request" level and sets a separate timeout for each
// HTTP request made as part of a "service request."
.with_call_attempt_timeout(TriState::Set(Duration::from_secs(2))),
)
.with_http_timeouts(
timeout::Http::new()
// A limit on the amount of time an application takes to attempt to read the first byte over
// an established, open connection after a write request.
// Also known as the "time to first byte" timeout.
.with_read_timeout(TriState::Set(Duration::from_secs(2)))
// A time limit for completing the connect-handshake. The time starts when
// making an initial connect attempt on a socket.
.with_connect_timeout(TriState::Set(Duration::from_secs(2))),
);

// Timeouts can be defined in your environment or AWS profile but in this example we
// overrule any that happen to be set
// NOTE: The two API call timeouts get set here
// You can define timeouts in your environment or your AWS profile, but in the following
// example, we overrule any previously set timeouts.
// NOTE: The two API call timeouts get set here.
let shared_config = aws_config::from_env()
.timeout_config(timeout_config.clone())
.load()
.await;

// These timeouts must also be passed to create the `Connector` that will handle our HTTP requests.
// If a timeout needs to be changed after this, we'd have to create a new `Connector`.
// NOTE: The read and connect timeouts get set here
// NOTE: The read and connect timeouts get set here.
let conn = DynConnector::new(
hyper_ext::Adapter::builder()
.timeout(&timeout_config)
.timeout(&timeout_config.http)
.build(conns::https()),
);
let s3_config = aws_sdk_s3::Config::from(&shared_config);
Expand Down
Loading

0 comments on commit 35373cb

Please sign in to comment.