minio-rs: refactored all functions#145
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors several S3 builder functions to simplify request construction and improve consistency. Key changes include:
- Changing the ToS3Request implementations to consume self instead of taking a reference.
- Replacing manual header and query parameter construction with an insert helper function.
- Updating module re-exports and import paths to reflect newly refactored functions.
Reviewed Changes
Copilot reviewed 122 out of 122 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/s3/builders/* | Refactored multiple builder functions to consume self and use the insert helper |
| src/s3/builders.rs | Updated module re-exports to include new functions like get_presigned_object_url |
| common/src/example.rs | Adjusted import paths to use the builders module for PostPolicy |
| benches/s3/common_benches.rs | Added explicit type annotation for request for clarity |
Comments suppressed due to low confidence (2)
src/s3/builders/get_bucket_tags.rs:76
- Changing the function signature to consume self instead of using &self alters builder reusability. Please confirm that the intended design is for these builder instances to be used only once.
fn to_s3request(self) -> Result<S3Request, Error> {
src/s3/builders/get_bucket_lifecycle.rs:42
- The region value is wrapped in an Option using Some(region) here, while in other implementations the region is passed directly as self.region. Please verify that the types and handling for region are consistent across all builders.
.region(Some(region))
refactored select_object_content refactor get_presigned_object_url refactor get_presigned_policy_form_data refactored upload-part-copy
8b7a739 to
6a15d89
Compare
7b21771 to
1b661fb
Compare
0bc2c74 to
944859d
Compare
There was a problem hiding this comment.
Copilot reviewed 188 out of 188 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
common/src/test_context.rs:27
- Ensure that all branches in TestContext's constructor consistently wrap the Client instance in an Arc. The diff only shows updates for one branch (the test branch), so verify that the non-test branch also creates an Arc to avoid type inconsistencies.
pub client: Arc<Client>,
|
@donatello I noticed a few functional differences between the various builders. I've tried to keep changes to a minimum, but this one really stands out and feels like a bug. Some functions (like get_bucket_encryption) use the region provided by the user directly when sending an S3Request. impl ToS3Request for GetBucketEncryption {
fn to_s3request(self) -> Result<S3Request, Error> {
check_bucket_name(&self.bucket, true)?;
Ok(S3Request::new(self.client, Method::GET)
.region(self.region) // HERE
.bucket(Some(self.bucket))
.query_params(insert(self.extra_query_params, "encryption"))
.headers(self.extra_headers.unwrap_or_default()))
}
}Whereas other functions (like get_bucket_lifecycle) use the region provided by the user to look up a cached region (and if it is not cached, makes a s3API get_region call) impl ToS3Request for GetBucketLifecycle {
fn to_s3request(self) -> Result<S3Request, Error> {
check_bucket_name(&self.bucket, true)?;
let region: String = self.client.get_region_cached(&self.bucket, &self.region)?;
Ok(S3Request::new(self.client, Method::GET)
.region(Some(region))
.bucket(Some(self.bucket))
.query_params(insert(self.extra_query_params, "lifecycle"))
.headers(self.extra_headers.unwrap_or_default()))
}
}I reckon that for calls to minio it probably doesn't matter, but since we should be S3 compatible, I assume we need to do the cached lookup in all the builders? Right, or can we just drop the cached lookup accross the board? |
4a590cc to
300557c
Compare
300557c to
562d52c
Compare
562d52c to
8278940
Compare
8278940 to
e49e230
Compare
9226043 to
774c9cd
Compare
87a495a to
4651cf6
Compare
4651cf6 to
4cccbe1
Compare
c48e61c to
c4888d6
Compare
355b8fc to
262a7c0
Compare
262a7c0 to
fd4c725
Compare
e1b41b6 to
78ebd60
Compare
448436e to
e9e2a97
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR refactors several functions and benchmark setups to improve consistency and code clarity across the repository. Key changes include refactoring the CleanupGuard constructor and updating various builder function calls in the benchmarks to use client clones and the new method signatures; additional minor dependency updates in Cargo.toml and new example additions support these refactors.
Reviewed Changes
Copilot reviewed 213 out of 213 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| common/src/cleanup_guard.rs | Refactored CleanupGuard::new to accept a Client by value and a bucket name as Into; error logging now silently suppressed in Drop. |
| benches/s3/common_benches.rs | Updated CleanupGuard instantiation to use client.clone() as required by the refactored API. |
| benches/s3/* | Updated several benchmark functions to use the new builder patterns and incorporated skip_express_mode checks. |
| Cargo.toml | Minor version updates to dependencies and addition of a new example for the append_object feature. |
| .github/workflows/rust.yml | Updated workflow step naming for running S3 tests. |
refactored stat_object
refactored select_object_content
refactor get_presigned_object_url
refactor get_presigned_policy_form_data
refactored upload-part-copy