-
Notifications
You must be signed in to change notification settings - Fork 131
feat(storage): add feature flag and models for appendable upload #5631
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
Open
vsharonlynn
wants to merge
3
commits into
googleapis:main
Choose a base branch
from
vsharonlynn:feat/storage-appendable-upload
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+112
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -310,6 +310,61 @@ pub struct WriteObjectRequest { | |||||
| pub params: Option<crate::model::CommonObjectRequestParams>, | ||||||
| } | ||||||
|
|
||||||
| #[cfg(google_cloud_unstable_storage_bidi)] | ||||||
| /// Represents the parameters of a request to open a new object for exclusive appends. | ||||||
| /// | ||||||
| /// This type might be used in mocks of the `Storage` client. | ||||||
| #[derive(Debug, PartialEq)] | ||||||
| #[non_exhaustive] | ||||||
| pub struct OpenAppendableObjectRequest { | ||||||
| /// The object attributes and pre-conditions for the open operation. | ||||||
| pub spec: Box<crate::model::WriteObjectSpec>, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unclear why you are using |
||||||
| /// Additional request parameters. | ||||||
| pub params: Option<crate::model::CommonObjectRequestParams>, | ||||||
| } | ||||||
|
|
||||||
| #[cfg(google_cloud_unstable_storage_bidi)] | ||||||
| /// Represents the parameters of a request to reopen an existing object for appends. | ||||||
| /// | ||||||
| /// This type might be used in mocks of the `Storage` client. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same nit:
Suggested change
|
||||||
| #[derive(Debug, PartialEq)] | ||||||
| #[non_exhaustive] | ||||||
| pub struct ReopenAppendableObjectRequest { | ||||||
| /// The bucket containing the target object. | ||||||
| pub bucket: String, | ||||||
| /// The target object name. | ||||||
| pub object: String, | ||||||
| /// The target object generation to append to. | ||||||
| pub generation: i64, | ||||||
| /// If set, return an error if the current metageneration does not match the value. | ||||||
| pub if_metageneration_match: Option<i64>, | ||||||
| /// If set, return an error if the current metageneration matches the value. | ||||||
| pub if_metageneration_not_match: Option<i64>, | ||||||
| /// A routing token from a previous operation. | ||||||
| pub routing_token: Option<String>, | ||||||
| /// A write handle from a previous operation. | ||||||
| pub write_handle: Option<bytes::Bytes>, | ||||||
| /// Additional request parameters. | ||||||
| pub params: Option<crate::model::CommonObjectRequestParams>, | ||||||
| } | ||||||
|
|
||||||
| #[cfg(google_cloud_unstable_storage_bidi)] | ||||||
| impl From<ReopenAppendableObjectRequest> for crate::google::storage::v2::AppendObjectSpec { | ||||||
| fn from(value: ReopenAppendableObjectRequest) -> Self { | ||||||
| Self { | ||||||
| bucket: value.bucket, | ||||||
| object: value.object, | ||||||
| generation: value.generation, | ||||||
| if_metageneration_match: value.if_metageneration_match, | ||||||
| if_metageneration_not_match: value.if_metageneration_not_match, | ||||||
| routing_token: value.routing_token, | ||||||
| write_handle: value | ||||||
| .write_handle | ||||||
| .map(|h| crate::google::storage::v2::BidiWriteHandle { handle: h }), | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| #[cfg(test)] | ||||||
| pub(crate) mod tests { | ||||||
| use super::*; | ||||||
|
|
@@ -429,4 +484,44 @@ pub(crate) mod tests { | |||||
| assert_eq!(key_aes_256.to_string(), key_base64); | ||||||
| Ok(()) | ||||||
| } | ||||||
|
|
||||||
| #[cfg(google_cloud_unstable_storage_bidi)] | ||||||
| #[test] | ||||||
| fn test_open_appendable_object_request() { | ||||||
| let req = OpenAppendableObjectRequest { | ||||||
| spec: Box::new(crate::model::WriteObjectSpec::default()), | ||||||
| params: None, | ||||||
| }; | ||||||
| assert_eq!(req.spec.resource, None); | ||||||
| assert_eq!(req.params, None); | ||||||
| } | ||||||
|
|
||||||
| #[cfg(google_cloud_unstable_storage_bidi)] | ||||||
| #[test] | ||||||
| fn test_reopen_appendable_object_request_from() { | ||||||
| let req = ReopenAppendableObjectRequest { | ||||||
| bucket: "my-bucket".into(), | ||||||
| object: "my-object".into(), | ||||||
| generation: 42, | ||||||
| if_metageneration_match: Some(1), | ||||||
| if_metageneration_not_match: Some(2), | ||||||
| routing_token: Some("token".into()), | ||||||
| write_handle: Some(bytes::Bytes::from("handle")), | ||||||
| params: None, | ||||||
| }; | ||||||
|
|
||||||
| let spec = crate::google::storage::v2::AppendObjectSpec::from(req); | ||||||
| assert_eq!(spec.bucket, "my-bucket"); | ||||||
| assert_eq!(spec.object, "my-object"); | ||||||
| assert_eq!(spec.generation, 42); | ||||||
| assert_eq!(spec.if_metageneration_match, Some(1)); | ||||||
| assert_eq!(spec.if_metageneration_not_match, Some(2)); | ||||||
| assert_eq!(spec.routing_token, Some("token".into())); | ||||||
| assert_eq!( | ||||||
| spec.write_handle, | ||||||
| Some(crate::google::storage::v2::BidiWriteHandle { | ||||||
| handle: bytes::Bytes::from("handle") | ||||||
| }) | ||||||
| ); | ||||||
| } | ||||||
| } | ||||||
This file contains hidden or 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 hidden or 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 2025 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Appendable object uploads (unstable). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: