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

refactor: Polish Writer API by merging append and write together #2036

Merged
merged 8 commits into from
Apr 19, 2023

Conversation

Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented Apr 19, 2023

This PR introduces the following changes:

  • Remove append from OpWrite: this arg is confusing.
  • Add content_length in OpWrite so that services can handle sized and unsized input by themselves

After all these changes, users only need to use write instead of append.


This change will make our writer's behavior more easy to understand.

Xuanwo added 4 commits April 19, 2023 15:58
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
@Xuanwo Xuanwo requested a review from suyanhanx April 19, 2023 09:27
core/src/types/ops.rs Show resolved Hide resolved
core/src/types/ops.rs Show resolved Hide resolved
@suyanhanx
Copy link
Member

Seems like you're using write instead of append. Please append this change to desc.

@Xuanwo
Copy link
Member Author

Xuanwo commented Apr 19, 2023

Seems like you're using write instead of append. Please append this change to desc.

DONE.

Copy link
Member

@suyanhanx suyanhanx left a comment

Choose a reason for hiding this comment

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

LGTM on ci green.

Signed-off-by: Xuanwo <[email protected]>
@suyanhanx
Copy link
Member

If users want to overwrite multiple times and then rollback, they will no longer be able to use the writer to do so.

WDYT?

@Xuanwo
Copy link
Member Author

Xuanwo commented Apr 19, 2023

If users want to overwrite multiple times and then rollback, they will no longer be able to use the writer to do so.

I didn't understand these use cases. Could you provide more details?

@suyanhanx
Copy link
Member

I didn't understand these use cases. Could you provide more details?

I think this is a problem of mixing write and append and not being able to distinguish between the two operations.

@Xuanwo
Copy link
Member Author

Xuanwo commented Apr 19, 2023

No, we are confused many things together here.

After this PRs change, there is no append concept, we have two different write uses cases: Sized and Unsized.

If users specified the size for write operation and provide all data with it, we can write with oneshot. Otherwise, services need to handle it in different ways: append, multipart upload, range write, ...

op.write() is exactly this case: we know the size and we have all data.
op.writer() is the other case: we don't know the size in advance, and services need to handle it by different ways.

In general, we will hide all the impelment details inside services. The only thing for users to use is write, and the only choice for users is specify the size or not.

@suyanhanx
Copy link
Member

No, we are confused many things together here.

After this PRs change, there is no append concept, we have two different write uses cases: Sized and Unsized.

If users specified the size for write operation and provide all data with it, we can write with oneshot. Otherwise, services need to handle it in different ways: append, multipart upload, range write, ...

op.write() is exactly this case: we know the size and we have all data. op.writer() is the other case: we don't know the size in advance, and services need to handle it by different ways.

In general, we will hide all the impelment details inside services. The only thing for users to use is write, and the only choice for users is specify the size or not.

Great explanation! I think this needs to be in the documentation.

@Xuanwo Xuanwo merged commit 56e0c6a into main Apr 19, 2023
@Xuanwo Xuanwo deleted the refactor-writer branch April 19, 2023 10:10
@Xuanwo Xuanwo mentioned this pull request Apr 23, 2023
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.

3 participants