Skip to content

Commit

Permalink
feat: disable_write_with_if_match
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank-III committed Nov 28, 2024
1 parent 9b94a34 commit 928449b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ runs:
OPENDAL_S3_SECRET_ACCESS_KEY=demo
OPENDAL_S3_REGION=us-east-1
OPENDAL_S3_ENABLE_VERSIONING=true
OPENDAL_S3_DISABLE_WRITE_WITH_IF_MATCH=on
EOF
1 change: 1 addition & 0 deletions .github/services/s3/ceph_rados_s3/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ runs:
OPENDAL_S3_ACCESS_KEY_ID=demo
OPENDAL_S3_SECRET_ACCESS_KEY=demo
OPENDAL_S3_REGION=us-east-1
OPENDAL_S3_DISABLE_WRITE_WITH_IF_MATCH=on
EOF
9 changes: 8 additions & 1 deletion core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ impl S3Builder {
self
}

/// Disable write with if match so that opendal will not send write request with if match headers.
pub fn disable_write_with_if_match(mut self) -> Self {
self.config.disable_write_with_if_match = true;
self
}

/// Detect region of S3 bucket.
///
/// # Args
Expand Down Expand Up @@ -878,6 +884,7 @@ impl Builder for S3Builder {
client,
batch_max_operations,
checksum_algorithm,
disable_write_with_if_match: self.config.disable_write_with_if_match,
}),
})
}
Expand Down Expand Up @@ -924,7 +931,7 @@ impl Access for S3Backend {
write_can_multi: true,
write_with_cache_control: true,
write_with_content_type: true,
write_with_if_match: true,
write_with_if_match: !self.core.disable_write_with_if_match,
write_with_if_not_exists: true,
write_with_user_metadata: true,

Expand Down
4 changes: 4 additions & 0 deletions core/src/services/s3/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ pub struct S3Config {
/// Available options:
/// - "crc32c"
pub checksum_algorithm: Option<String>,
/// Disable write with if match so that opendal will not send write request with if match headers.
///
/// For example, Ceph RADOS S3 doesn't support write with if match.
pub disable_write_with_if_match: bool,
}

impl Debug for S3Config {
Expand Down
1 change: 1 addition & 0 deletions core/src/services/s3/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub struct S3Core {
pub client: HttpClient,
pub batch_max_operations: usize,
pub checksum_algorithm: Option<ChecksumAlgorithm>,
pub disable_write_with_if_match: bool,
}

impl Debug for S3Core {
Expand Down
3 changes: 2 additions & 1 deletion core/src/services/s3/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ This service can be used to:
- `server_side_encryption_customer_algorithm`: Set the server_side_encryption_customer_algorithm for backend.
- `server_side_encryption_customer_key`: Set the server_side_encryption_customer_key for backend.
- `server_side_encryption_customer_key_md5`: Set the server_side_encryption_customer_key_md5 for backend.
- `disable_config_load`: Disable aws config load from env
- `disable_config_load`: Disable aws config load from env.
- `enable_virtual_host_style`: Enable virtual host style.
- `disable_write_with_if_match`: Diable write with if match.

Check warning on line 33 in core/src/services/s3/docs.md

View workflow job for this annotation

GitHub Actions / typos

"Diable" should be "Disable".

Refer to [`S3Builder`]'s public API docs for more information.

Expand Down

0 comments on commit 928449b

Please sign in to comment.