feat(storage): Add delete object source field in ComposeObject API#16094
feat(storage): Add delete object source field in ComposeObject API#16094v-pratap wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the DeleteSourceObjects option for ComposeObject requests, implementing support in both gRPC and REST paths. It also includes integration tests to verify the behavior when the option is enabled or disabled. Feedback was provided to simplify the option retrieval logic using value_or(false) for better readability and to add a docstring to the new public-facing DeleteSourceObjects parameter.
| if (HasOption<DeleteSourceObjects>() && GetOption<DeleteSourceObjects>().value()) { | ||
| compose_object_payload_json["deleteSourceObjects"] = true; | ||
| } |
There was a problem hiding this comment.
For consistency with other parts of the codebase and to improve readability, you can use value_or(false) instead of checking HasOption and then calling value(). This simplifies the logic while maintaining the same behavior and aligns with the preference for defensive code.
if (GetOption<DeleteSourceObjects>().value_or(false)) {
compose_object_payload_json["deleteSourceObjects"] = true;
}References
- Prefer defensive code, such as explicit ok() checks, even if they seem redundant based on the current implementation of a framework, as the framework's contract may change in the future.
| struct DeleteSourceObjects | ||
| : public internal::WellKnownParameter<DeleteSourceObjects, bool> { | ||
| using WellKnownParameter<DeleteSourceObjects, bool>::WellKnownParameter; | ||
| static char const* well_known_parameter_name() { | ||
| return "deleteSourceObjects"; | ||
| } | ||
| }; |
There was a problem hiding this comment.
New public-facing parameters should include a docstring explaining their purpose, consistent with other parameters in this file. This helps users understand the functionality when using the library.
/**
* If true, the source objects are deleted after a successful compose.
*/
struct DeleteSourceObjects
: public internal::WellKnownParameter<DeleteSourceObjects, bool> {
using WellKnownParameter<DeleteSourceObjects, bool>::WellKnownParameter;
static char const* well_known_parameter_name() {
return "deleteSourceObjects";
}
};
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16094 +/- ##
=======================================
Coverage 92.70% 92.70%
=======================================
Files 2353 2353
Lines 218352 218412 +60
=======================================
+ Hits 202418 202479 +61
+ Misses 15934 15933 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.