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

re-organize crate structure part one #36

Merged
merged 5 commits into from
Jul 24, 2024
Merged

re-organize crate structure part one #36

merged 5 commits into from
Jul 24, 2024

Conversation

aajtodd
Copy link
Contributor

@aajtodd aajtodd commented Jul 24, 2024

Issue #, if available:
#35

Description of changes:

In order to keep these PRs somewhat reasonable I'm going to stop here but we aren't done. This is the first of likely 2-3 PRs to get to the desired state.

NOTE: This PR does not change any implementation details of upload/download. It is largely re-organization. The fluent builder boilerplate adds nearly 1K lines.

  • rename request/response types to "input" / "output" (as suggested).
  • Remove Uploader and move the internals as the implementation details of the new Upload operation.
  • Introduce the transfer manager Client that transfer operations will be initiated from. Currently only upload is mostly fleshed out

Future PRs

  • Remove Downloader and move it's internals into the Download operation.
  • Re-think where the streaming types live (likely with the individual operations rather than io module but up for debate).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aajtodd aajtodd requested a review from a team as a code owner July 24, 2024 14:18
aws-s3-transfer-manager/src/client.rs Outdated Show resolved Hide resolved
&self.target_part_size
}

// TODO(design) - should we separate upload/download part size and concurrency settings?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think not. I can see them each having different defaults but I'd be surprised if they had exclusive settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Download doesn't have a minimum part size of 5 MiB though. We can do downloads in smaller ranges (if of course it is beneficial to do so).

aws-s3-transfer-manager/src/operation/upload.rs Outdated Show resolved Hide resolved
let ctx = new_context(handle, input);
let mut handle = UploadHandle::new(ctx);

// MPU has max of 10K parts which requires us to know the upper bound on the content length (today anyway)
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment implicitly refers to the current state of the code.

Suggested change
// MPU has max of 10K parts which requires us to know the upper bound on the content length (today anyway)
// MPU has max of 10K parts which requires us to know the upper bound on the content length

Copy link
Contributor

Choose a reason for hiding this comment

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

the "today anyway" refers to the current state of S3. It might very well be different in a few years if S3 bumps up its max object size

Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

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

LGTM. FYI, src/io contains the old style of mod.rs whereas the rest of the repo doesn't follow that style. We probably want src/io/mod.rs to follow the rest of the repo, but that cleanup doesn't have to be done in this PR.

@aajtodd
Copy link
Contributor Author

aajtodd commented Jul 24, 2024

LGTM. FYI, src/io contains the old style of mod.rs whereas the rest of the repo doesn't follow that style. We probably want src/io/mod.rs to follow the rest of the repo, but that cleanup doesn't have to be done in this PR.

I don't know that I agree. We use mod.rs in the runtime in places (e.g. here). Mostly though if a module file only contains other mod declarations and re-exports then not having the correspondingly named module file in the parent directory can help reduce clutter and cognitive load IMO.

e.g.

src/
  foo/
       mod.rs
       bar.rs
       baz.rs
  quux.rs
// foo/mod.rs contents
pub mod bar;
mod baz;
pub use baz::Baz;

vs

src/
    foo.rs
    quux.rs
    foo/
        bar.rs
        baz.rs
// src/foo.rs contents

pub mod bar;
mod baz;
pub use baz::Baz;

I think each has their place personally. If others feel strongly on favoring only one style though it's not a hill I want to die on.

@ysaito1001
Copy link
Contributor

I don't know that I agree. We use mod.rs in the runtime in places (e.g. here).

FYI, that is a leftover before we had switched to without-mod-rs world in smithy-rs. And modules without mod.rs were something I was told by peers when I joined so I'm simply passing that info here for consistency. That said, the community has both styles and I don't mean to govern the style in this repo, so feel free to take your pick.

Copy link
Contributor

@graebm graebm left a comment

Choose a reason for hiding this comment

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

I left some rambling comments, but I see now how this mirrors the organization of the SDK, so like ... I get it

Comment on lines +167 to +170
.client(s3_client)
.build();

let tm = aws_s3_transfer_manager::Client::new(tm_config);
Copy link
Contributor

Choose a reason for hiding this comment

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

Will it be confusing to call it aws_s3_transfer_manager::Client but also the aws_sdk_s3::Client is in the mix? User code is going to end up with 2 "S3 clients". Should it be aws_s3_transfer_manager::TransferManager instead?

Or is that just normal? Everything is a "::Client", it's namespaced by the module name, and users are used to that, and give good disambiguating variable names when they both appear side-by-side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to leave it for now but feel free to add it to the bikeshed issue. I can go either way, I do think it's redundant a bit when the crate/module name has transfer manager in it, though the SEP says it should be named TransferManager so maybe we call it that. Users can give an alias to an import to disambiguate e.g. use aws_s3_transfer_manager::Client as TransferManager. Also my hope is that the need for users to instantiate their own aws_sdk_s3::Client is rare when we add some convenience "loader" functions.

/// }
///
/// ```
pub fn upload(&self) -> crate::operation::upload::builders::UploadFluentBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to say it seems it weird that the returned type has such a long module path, and wondered if we want to shorten it at least for public consumption? But I see that this mirrors the path to aws_sdk_s3's fluent builders, so it's probably good

I'm seeing now how the module organization here really mirrors the SDK's module organization, which seems good to do.

no need to respond. just sharing my mental journey

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes no difference to the generated docs or how users consume it FWIW. The end result to a user is the same as:

use crate::operation::upload::builders::UploadFluentBuilder;

...

pub fn upload(&self) -> UploadFluentBuilder

/// the multipart upload ID
pub(crate) upload_id: Option<String>,
/// the original request (NOTE: the body will have been taken for processing, only the other fields remain)
pub(crate) request: Arc<UploadRequest>,
pub(crate) request: Arc<UploadInput>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub(crate) request: Arc<UploadInput>,
pub(crate) input: Arc<UploadInput>,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll take another pass at cleaning up request/response naming in following PR(s). Good catch.

@aajtodd aajtodd merged commit 4b4496d into main Jul 24, 2024
13 of 14 checks passed
@aajtodd aajtodd deleted the atodd/crate-org branch July 24, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants