Skip to content

Commit

Permalink
better enable_write_with_append
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank-III committed Dec 24, 2024
1 parent 82cc745 commit 6107180
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
15 changes: 9 additions & 6 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,12 @@ impl S3Builder {
self
}

/// Enable write with append so that opendal will send write request with append headers.
pub fn enable_write_with_append(mut self) -> Self {
self.config.enable_write_with_append = true;
self
}

/// Detect region of S3 bucket.
///
/// # Args
Expand Down Expand Up @@ -895,6 +901,7 @@ impl Builder for S3Builder {
checksum_algorithm,
delete_max_size,
disable_write_with_if_match: self.config.disable_write_with_if_match,
enable_write_with_append: self.config.enable_write_with_append,
}),
})
}
Expand Down Expand Up @@ -942,12 +949,8 @@ impl Access for S3Backend {
write: true,
write_can_empty: true,
write_can_multi: true,
// Only S3 Express One Zone storage class supports append.
write_can_append: self
.core
.default_storage_class
.as_ref()
.is_some_and(|v| v == "EXPRESS_ONEZONE"),
write_can_append: self.core.enable_write_with_append,

write_with_cache_control: true,
write_with_content_type: true,
write_with_content_encoding: true,
Expand Down
3 changes: 3 additions & 0 deletions core/src/services/s3/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ pub struct S3Config {
///
/// For example, Ceph RADOS S3 doesn't support write with if match.
pub disable_write_with_if_match: bool,

/// Enable write with append so that opendal will send write request with append headers.
pub enable_write_with_append: 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 @@ -102,6 +102,7 @@ pub struct S3Core {
pub delete_max_size: usize,
pub checksum_algorithm: Option<ChecksumAlgorithm>,
pub disable_write_with_if_match: bool,
pub enable_write_with_append: bool,
}

impl Debug for S3Core {
Expand Down

0 comments on commit 6107180

Please sign in to comment.