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

platform: add aws s3 storage #99

Merged
merged 19 commits into from
Nov 17, 2021
Merged

platform: add aws s3 storage #99

merged 19 commits into from
Nov 17, 2021

Conversation

zojw
Copy link
Contributor

@zojw zojw commented Nov 12, 2021

ref #68

move demo-1's aws s3 code to here and adapt new Storage trait

Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @zojw ! Comments inline.

Apart of comments I'd like to know why remote storage stay under storage crate and s3 storage stay under platform crate. It looks like we divide project layout with two nonorthogonal dimensions.

src/platform/src/aws/s3/mod.rs Outdated Show resolved Hide resolved
src/storage/src/error.rs Outdated Show resolved Hide resolved
tools/ci/licenserc.yml Outdated Show resolved Hide resolved
src/storage/src/bucket.rs Outdated Show resolved Hide resolved
@zojw
Copy link
Contributor Author

zojw commented Nov 12, 2021

Thanks for your contribution @zojw ! Comments inline.

Apart of comments I'd like to know why remote storage stay under storage crate and s3 storage stay under platform crate. It looks like we divide project layout with two nonorthogonal dimensions.

Thanks for review :) @tisonkun

add s3 storage under platform is introduced by another PR's comment #86 (comment)

for my understanding, in the storage crate, we only provide default implement (memory, remote, fs..), for third-part storage, users can implement it by their self's crate. platform maybe can be viewed as one third-part implement~

@huachaohuang
Copy link
Contributor

Apart of comments I'd like to know why remote storage stay under storage crate and s3 storage stay under platform crate. It looks like we divide project layout with two nonorthogonal dimensions.

@tisonkun I think the discussion started here. My mindset is to put things that don't rely on third-party services in the component crate, and put vendor-related things in the platform together.

@zojw I further suggest that we make aws a sub-crate under platform. Then we may use features to conditional include different vendors.

@zojw
Copy link
Contributor Author

zojw commented Nov 16, 2021

@tisonkun @huachaohuang addressed some comments, PTAL if free, thanks~

Copy link
Contributor

@huachaohuang huachaohuang left a comment

Choose a reason for hiding this comment

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

I see this is your first PR, let work together to improve it a little bit :)

src/platform/aws/src/s3/bucket.rs Outdated Show resolved Hide resolved
src/platform/aws/src/s3/bucket.rs Outdated Show resolved Hide resolved
src/platform/aws/src/s3/bucket.rs Outdated Show resolved Hide resolved
src/platform/aws/src/s3/bucket.rs Outdated Show resolved Hide resolved
src/platform/aws/src/s3/object.rs Outdated Show resolved Hide resolved
src/platform/aws/src/s3/storage.rs Outdated Show resolved Hide resolved
.map_err(Error::from)
}

async fn create_new_bucket(&self, name: &str) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you move it to an S3Client, you can rename it to create_bucket. "create" and "new" are redundant, IMO.

src/platform/aws/src/s3/storage.rs Outdated Show resolved Hide resolved
src/platform/aws/src/s3/storage.rs Show resolved Hide resolved
src/platform/aws/src/s3/storage.rs Outdated Show resolved Hide resolved
use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
Copy link
Contributor

Choose a reason for hiding this comment

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

We may define some common errors instead of simply exporting all these errors in the future. I think users have no idea how to handle these individual errors. But we can leave it this way for now, IMO.

Copy link
Contributor Author

@zojw zojw Nov 16, 2021

Choose a reason for hiding this comment

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

+1 maybe we can refactor this later, for the platform IMHO, maybe we need still need an error mapping between the vendor's error and engula's error, but it should not be one-one mapping, we can hide some user not care detail, but it seems highly related to upper layer usage, maybe we can do it when upper layer and vendor's logic be clear :)

@huachaohuang
Copy link
Contributor

@zojw I see your PR doesn't compile because of something related to a 'static lifetime. It's OK to specify 'static lifetime bound in trait. I think this post is helpful.

src/platform/aws/src/s3/mod.rs Outdated Show resolved Hide resolved
src/platform/aws/src/s3/client.rs Outdated Show resolved Hide resolved
src/platform/aws/src/s3/storage.rs Outdated Show resolved Hide resolved
@tisonkun
Copy link
Contributor

tisonkun commented Nov 17, 2021

@zojw I see your PR doesn't compile because of something related to a 'static lifetime. It's OK to specify 'static lifetime bound in trait. I think this post is helpful.

@huachaohuang you can click the Approve and run button above to let ci do checks for you.

image

@huachaohuang
Copy link
Contributor

@huachaohuang you can click the Approve and run button above to let ci do checks for you.

Yeah, I have done that before. But it seems that I need to click that every time it is updated.

@tisonkun
Copy link
Contributor

@huachaohuang you can do it every time give the first-time contribution a review or when you think it ok to test :)

Anyway, tests should be run before you merge the pull request. This restriction is for first-time contribution or on a fork only, you can check out this post.

Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
tisonkun
tisonkun previously approved these changes Nov 17, 2021
Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

LGTM. The two outstanding comments aren't blockers IMO.

@huachaohuang
Copy link
Contributor

@zojw please let me know if it is ready.

Signed-off-by: zojw <robi@hey.com>
@zojw
Copy link
Contributor Author

zojw commented Nov 17, 2021

@zojw please let me know if it is ready.

except #99 (comment) need some discuss, others are ready @huachaohuang

Copy link
Contributor

@huachaohuang huachaohuang left a comment

Choose a reason for hiding this comment

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

return Ok(());
}

while data.len() > UPLOAD_PART_SIZE * 2 {
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 the idea is to upload UPLOAD_PART_SIZE at a time instead of UPLOAD_PART_SIZE * 2?

Signed-off-by: zojw <robi@hey.com>
Signed-off-by: zojw <robi@hey.com>
huachaohuang
huachaohuang previously approved these changes Nov 17, 2021
Copy link
Contributor

@huachaohuang huachaohuang left a comment

Choose a reason for hiding this comment

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

Everything looks great now. @zojw @tisonkun thanks for your contribution. I think we have some very fruitful discussions in this PR!

Signed-off-by: zojw <robi@hey.com>
@huachaohuang huachaohuang merged commit bd69f2e into engula:main Nov 17, 2021
@zojw zojw deleted the s3-storage branch November 17, 2021 15:11
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.

None yet

4 participants