You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "geetanshjuneja (via GitHub)" <gi...@apache.org> on 2025/01/05 15:52:04 UTC
[PR] feat(services/cos): Added user metadata support for cos service [opendal]
geetanshjuneja opened a new pull request, #5510:
URL: https://github.com/apache/opendal/pull/5510
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes cos service task for #4842 .
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking-changes` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "geetanshjuneja (via GitHub)" <gi...@apache.org>.
geetanshjuneja commented on code in PR #5510:
URL: https://github.com/apache/opendal/pull/5510#discussion_r1904200822
##########
core/src/services/cos/core.rs:
##########
@@ -184,6 +185,20 @@ impl CosCore {
req = req.header("x-cos-forbid-overwrite", "true")
}
+ // Set user metadata headers.
+ if let Some(user_metadata) = args.user_metadata() {
+ for (key, value) in user_metadata {
+ // before insert user defined metadata header, add prefix to the header name
+ if !self.check_user_metadata_key(key) {
Review Comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #5510:
URL: https://github.com/apache/opendal/pull/5510#discussion_r1904094719
##########
core/src/services/cos/core.rs:
##########
@@ -184,6 +185,20 @@ impl CosCore {
req = req.header("x-cos-forbid-overwrite", "true")
}
+ // Set user metadata headers.
+ if let Some(user_metadata) = args.user_metadata() {
+ for (key, value) in user_metadata {
+ // before insert user defined metadata header, add prefix to the header name
+ if !self.check_user_metadata_key(key) {
Review Comment:
Hi, I'm not sure if it's a good idea to check user's metadata key. Let's skip it.
##########
core/src/services/cos/core.rs:
##########
@@ -434,6 +463,32 @@ impl CosCore {
self.sign(&mut req).await?;
self.send(req).await
}
+
+ // According to https://www.tencentcloud.com/document/product/436/7746
+ // there are some limits in user defined metadata key
+ fn check_user_metadata_key(&self, key: &str) -> bool {
+ key.chars().all(|c| c != '_')
+ }
+
+ /// parse_metadata will parse http headers(including standards http headers
+ /// and user defined metadata header) into Metadata.
+ ///
+ /// # Arguments
+ ///
+ /// * `user_metadata_prefix` is the prefix of user defined metadata key
+ ///
+ /// # Notes
+ ///
+ /// before return the user defined metadata, we'll strip the user_metadata_prefix from the key
+ pub fn parse_metadata(&self, path: &str, headers: &HeaderMap) -> Result<Metadata> {
Review Comment:
I think this function might be slightly overengineered.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "geetanshjuneja (via GitHub)" <gi...@apache.org>.
geetanshjuneja commented on code in PR #5510:
URL: https://github.com/apache/opendal/pull/5510#discussion_r1904203724
##########
core/src/services/cos/core.rs:
##########
@@ -434,6 +463,32 @@ impl CosCore {
self.sign(&mut req).await?;
self.send(req).await
}
+
+ // According to https://www.tencentcloud.com/document/product/436/7746
+ // there are some limits in user defined metadata key
+ fn check_user_metadata_key(&self, key: &str) -> bool {
+ key.chars().all(|c| c != '_')
+ }
+
+ /// parse_metadata will parse http headers(including standards http headers
+ /// and user defined metadata header) into Metadata.
+ ///
+ /// # Arguments
+ ///
+ /// * `user_metadata_prefix` is the prefix of user defined metadata key
+ ///
+ /// # Notes
+ ///
+ /// before return the user defined metadata, we'll strip the user_metadata_prefix from the key
+ pub fn parse_metadata(&self, path: &str, headers: &HeaderMap) -> Result<Metadata> {
Review Comment:
What do you mean by overengineered? What do I need to change in this fn?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #5510:
URL: https://github.com/apache/opendal/pull/5510
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #5510:
URL: https://github.com/apache/opendal/pull/5510#discussion_r1905079537
##########
core/src/services/cos/core.rs:
##########
@@ -434,6 +463,32 @@ impl CosCore {
self.sign(&mut req).await?;
self.send(req).await
}
+
+ // According to https://www.tencentcloud.com/document/product/436/7746
+ // there are some limits in user defined metadata key
+ fn check_user_metadata_key(&self, key: &str) -> bool {
+ key.chars().all(|c| c != '_')
+ }
+
+ /// parse_metadata will parse http headers(including standards http headers
+ /// and user defined metadata header) into Metadata.
+ ///
+ /// # Arguments
+ ///
+ /// * `user_metadata_prefix` is the prefix of user defined metadata key
+ ///
+ /// # Notes
+ ///
+ /// before return the user defined metadata, we'll strip the user_metadata_prefix from the key
+ pub fn parse_metadata(&self, path: &str, headers: &HeaderMap) -> Result<Metadata> {
Review Comment:
Hi, I would like to remove this function and expand it instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "geetanshjuneja (via GitHub)" <gi...@apache.org>.
geetanshjuneja commented on PR #5510:
URL: https://github.com/apache/opendal/pull/5510#issuecomment-2572487354
@Xuanwo can you plz look into this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "geetanshjuneja (via GitHub)" <gi...@apache.org>.
geetanshjuneja commented on code in PR #5510:
URL: https://github.com/apache/opendal/pull/5510#discussion_r1904203724
##########
core/src/services/cos/core.rs:
##########
@@ -434,6 +463,32 @@ impl CosCore {
self.sign(&mut req).await?;
self.send(req).await
}
+
+ // According to https://www.tencentcloud.com/document/product/436/7746
+ // there are some limits in user defined metadata key
+ fn check_user_metadata_key(&self, key: &str) -> bool {
+ key.chars().all(|c| c != '_')
+ }
+
+ /// parse_metadata will parse http headers(including standards http headers
+ /// and user defined metadata header) into Metadata.
+ ///
+ /// # Arguments
+ ///
+ /// * `user_metadata_prefix` is the prefix of user defined metadata key
+ ///
+ /// # Notes
+ ///
+ /// before return the user defined metadata, we'll strip the user_metadata_prefix from the key
+ pub fn parse_metadata(&self, path: &str, headers: &HeaderMap) -> Result<Metadata> {
Review Comment:
Ok so should I remove this function and add the code directly into `stat` fn
##########
core/src/services/cos/core.rs:
##########
@@ -434,6 +463,32 @@ impl CosCore {
self.sign(&mut req).await?;
self.send(req).await
}
+
+ // According to https://www.tencentcloud.com/document/product/436/7746
+ // there are some limits in user defined metadata key
+ fn check_user_metadata_key(&self, key: &str) -> bool {
+ key.chars().all(|c| c != '_')
+ }
+
+ /// parse_metadata will parse http headers(including standards http headers
+ /// and user defined metadata header) into Metadata.
+ ///
+ /// # Arguments
+ ///
+ /// * `user_metadata_prefix` is the prefix of user defined metadata key
+ ///
+ /// # Notes
+ ///
+ /// before return the user defined metadata, we'll strip the user_metadata_prefix from the key
+ pub fn parse_metadata(&self, path: &str, headers: &HeaderMap) -> Result<Metadata> {
Review Comment:
Ok so should I remove this function and add the code directly into `stat` fn?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "geetanshjuneja (via GitHub)" <gi...@apache.org>.
geetanshjuneja commented on code in PR #5510:
URL: https://github.com/apache/opendal/pull/5510#discussion_r1904203724
##########
core/src/services/cos/core.rs:
##########
@@ -434,6 +463,32 @@ impl CosCore {
self.sign(&mut req).await?;
self.send(req).await
}
+
+ // According to https://www.tencentcloud.com/document/product/436/7746
+ // there are some limits in user defined metadata key
+ fn check_user_metadata_key(&self, key: &str) -> bool {
+ key.chars().all(|c| c != '_')
+ }
+
+ /// parse_metadata will parse http headers(including standards http headers
+ /// and user defined metadata header) into Metadata.
+ ///
+ /// # Arguments
+ ///
+ /// * `user_metadata_prefix` is the prefix of user defined metadata key
+ ///
+ /// # Notes
+ ///
+ /// before return the user defined metadata, we'll strip the user_metadata_prefix from the key
+ pub fn parse_metadata(&self, path: &str, headers: &HeaderMap) -> Result<Metadata> {
Review Comment:
What do you mean by overengineered?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(services/cos): Added user metadata support for cos service [opendal]
Posted by "geetanshjuneja (via GitHub)" <gi...@apache.org>.
geetanshjuneja commented on PR #5510:
URL: https://github.com/apache/opendal/pull/5510#issuecomment-2577703292
@Xuanwo I have made the changes that you suggested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org