Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK committed Dec 6, 2024
1 parent 9a61f4e commit 7f6070a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
6 changes: 0 additions & 6 deletions aws-s3-transfer-manager/examples/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ async fn do_download(args: Args) -> Result<(), BoxError> {
let tm_config = aws_s3_transfer_manager::from_env()
.concurrency(ConcurrencySetting::Explicit(args.concurrency))
.part_size(PartSize::Target(args.part_size))
.frame_metadata(Some(
FrameworkMetadata::new("some-framework", Some(Cow::Borrowed("1.3"))).unwrap(),
))
.load()
.await;

Expand Down Expand Up @@ -233,9 +230,6 @@ async fn do_upload(args: Args) -> Result<(), BoxError> {
let tm_config = aws_s3_transfer_manager::from_env()
.concurrency(ConcurrencySetting::Explicit(args.concurrency))
.part_size(PartSize::Target(args.part_size))
.frame_metadata(Some(
FrameworkMetadata::new("some-framework", Some(Cow::Borrowed("1.3"))).unwrap(),
))
.load()
.await;

Expand Down
22 changes: 12 additions & 10 deletions aws-s3-transfer-manager/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Config {
multipart_threshold: PartSize,
target_part_size: PartSize,
concurrency: ConcurrencySetting,
frame_metadata: Option<FrameworkMetadata>,
framework_metadata: Option<FrameworkMetadata>,
client: aws_sdk_s3::client::Client,
}

Expand All @@ -46,9 +46,10 @@ impl Config {
&self.concurrency
}

/// Returns the name of the app that is using the transfer manager, if it was provided.
pub fn frame_metadata(&self) -> Option<&FrameworkMetadata> {
self.frame_metadata.as_ref()
#[doc(hidden)]
/// Returns the framework metadata setting when using transfer manager.
pub fn framework_metadata(&self) -> Option<&FrameworkMetadata> {
self.framework_metadata.as_ref()
}

/// The Amazon S3 client instance that will be used to send requests to S3.
Expand All @@ -63,7 +64,7 @@ pub struct Builder {
multipart_threshold_part_size: PartSize,
target_part_size: PartSize,
concurrency: ConcurrencySetting,
frame_metadata: Option<FrameworkMetadata>,
framework_metadata: Option<FrameworkMetadata>,
client: Option<aws_sdk_s3::Client>,
}

Expand Down Expand Up @@ -131,12 +132,13 @@ impl Builder {
self
}

/// Sets the name of the app that is using the client.
#[doc(hidden)]
/// Sets the framework metadata for the transfer manager.
///
/// This _optional_ name is used to identify the application in the user agent that
/// This _optional_ name is used to identify the framework using transfer manager in the user agent that
/// gets sent along with requests.
pub fn frame_metadata(mut self, frame_metadata: Option<FrameworkMetadata>) -> Self {
self.frame_metadata = frame_metadata;
pub fn framework_metadata(mut self, framework_metadata: Option<FrameworkMetadata>) -> Self {
self.framework_metadata = framework_metadata;
self
}

Expand All @@ -155,7 +157,7 @@ impl Builder {
multipart_threshold: self.multipart_threshold_part_size,
target_part_size: self.target_part_size,
concurrency: self.concurrency,
frame_metadata: self.frame_metadata,
framework_metadata: self.framework_metadata,
client: self.client.expect("client set"),
}
}
Expand Down
13 changes: 7 additions & 6 deletions aws-s3-transfer-manager/src/config/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ impl ConfigLoader {
self
}

/// Sets the name of the app that is using the client.
#[doc(hidden)]
/// Sets the framework metadata for the transfer manager.
///
/// This _optional_ name is used to identify the application in the user agent that
/// This _optional_ name is used to identify the framework using transfer manager in the user agent that
/// gets sent along with requests.
pub fn frame_metadata(mut self, frame_metadata: Option<FrameworkMetadata>) -> Self {
self.builder = self.builder.frame_metadata(frame_metadata);
pub fn framework_metadata(mut self, framework_metadata: Option<FrameworkMetadata>) -> Self {
self.builder = self.builder.framework_metadata(framework_metadata);
self
}

Expand All @@ -113,7 +114,7 @@ impl ConfigLoader {
let mut sdk_client_builder = aws_sdk_s3::config::Builder::from(&shared_config);

let interceptor = S3TransferManagerInterceptor {
frame_work_meta_data: self.builder.frame_metadata.clone(),
frame_work_meta_data: self.builder.framework_metadata.clone(),
};
sdk_client_builder.push_interceptor(S3TransferManagerInterceptor::into_shared(interceptor));
let builder = self
Expand All @@ -129,7 +130,7 @@ mod tests {
use aws_sdk_s3::config::Intercept;

#[tokio::test]
async fn load_with_frame_metadata_and_interceptor() {
async fn load_with_framework_metadata_and_interceptor() {
let config = crate::from_env()
.concurrency(ConcurrencySetting::Explicit(123))
.part_size(PartSize::Target(8))
Expand Down

0 comments on commit 7f6070a

Please sign in to comment.