-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move http utils into own module * add config loader and default to hyper-1.x http client
- Loading branch information
Showing
11 changed files
with
168 additions
and
44 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
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,68 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use crate::config::Builder; | ||
use crate::{ | ||
http, | ||
types::{ConcurrencySetting, PartSize}, | ||
Config, | ||
}; | ||
|
||
/// Load transfer manager [`Config`] from the environment. | ||
#[derive(Default, Debug)] | ||
pub struct ConfigLoader { | ||
builder: Builder, | ||
} | ||
|
||
impl ConfigLoader { | ||
/// Minimum object size that should trigger a multipart upload. | ||
/// | ||
/// The minimum part size is 5 MiB, any part size less than that will be rounded up. | ||
/// Default is [PartSize::Auto] | ||
pub fn multipart_threshold(mut self, threshold: PartSize) -> Self { | ||
self.builder = self.builder.multipart_threshold(threshold); | ||
self | ||
} | ||
|
||
/// The target size of each part when using a multipart upload to complete the request. | ||
/// | ||
/// When a request's content length is les than [`multipart_threshold`], | ||
/// this setting is ignored and a single [`PutObject`] request will be made instead. | ||
/// | ||
/// NOTE: The actual part size used may be larger than the configured part size if | ||
/// the current value would result in more than 10,000 parts for an upload request. | ||
/// | ||
/// Default is [PartSize::Auto] | ||
/// | ||
/// [`multipart_threshold`]: method@Self::multipart_threshold | ||
/// [`PutObject`]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html | ||
pub fn part_size(mut self, part_size: PartSize) -> Self { | ||
self.builder = self.builder.part_size(part_size); | ||
self | ||
} | ||
|
||
/// Set the concurrency level this component is allowed to use. | ||
/// | ||
/// This sets the maximum number of concurrent in-flight requests. | ||
/// Default is [ConcurrencySetting::Auto]. | ||
pub fn concurrency(mut self, concurrency: ConcurrencySetting) -> Self { | ||
self.builder = self.builder.concurrency(concurrency); | ||
self | ||
} | ||
|
||
/// Load the default configuration | ||
/// | ||
/// If fields have been overridden during builder construction, the override values will be | ||
/// used. Otherwise, the default values for each field will be provided. | ||
pub async fn load(self) -> Config { | ||
let shared_config = aws_config::from_env() | ||
.http_client(http::default_client()) | ||
.load() | ||
.await; | ||
let s3_client = aws_sdk_s3::Client::new(&shared_config); | ||
let builder = self.builder.client(s3_client); | ||
builder.build() | ||
} | ||
} |
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,15 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
use aws_smithy_experimental::hyper_1_0::{CryptoMode, HyperClientBuilder}; | ||
use aws_smithy_runtime_api::client::http::SharedHttpClient; | ||
|
||
pub(crate) mod header; | ||
|
||
/// The default HTTP client used by a transfer manager when not explicitly configured. | ||
pub(crate) fn default_client() -> SharedHttpClient { | ||
HyperClientBuilder::new() | ||
.crypto_mode(CryptoMode::AwsLc) | ||
.build_https() | ||
} |
File renamed without changes.
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
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