This is an automated email from the ASF dual-hosted git repository.
Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 0359b132a0 refactor(core)!: remove IntoMultipartCopyContext and
CompleteService pass-through wrappers (#8899)
0359b132a0 is described below
commit 0359b132a082e1f637ee6fbedccdff2f8b88acfb
Author: Xuanwo <[email protected]>
AuthorDate: Tue Nov 24 02:28:17 2026 +0800
refactor(core)!: remove IntoMultipartCopyContext and CompleteService
pass-through wrappers (#8899)
---
core/core/src/docs/upgrade.md | 8 +++++
core/core/src/layers/complete.rs | 25 +++++--------
core/core/src/raw/oio/copy/multipart_copy.rs | 52 +++++++++++++++-------------
core/services/s3/src/copier.rs | 3 +-
core/services/tos/src/copier.rs | 3 +-
5 files changed, 49 insertions(+), 42 deletions(-)
diff --git a/core/core/src/docs/upgrade.md b/core/core/src/docs/upgrade.md
index d1b780bf02..e655745f20 100644
--- a/core/core/src/docs/upgrade.md
+++ b/core/core/src/docs/upgrade.md
@@ -129,6 +129,14 @@ available bytes. Keep using `oio::Read::read` for an exact
bounded range.
`raw::oio::FlatLister` has been removed. Recursive listing simulation for
services without native recursive listing is provided by
[`SimulateLayer`][crate::layers::SimulateLayer] (enabled automatically with the
default `auto-simulate` feature). Use `SimulateLayer` instead of constructing
`oio::FlatLister` directly.
+### Explicit executor and capability in `oio::MultipartCopier::new`
+
+`raw::oio::IntoMultipartCopyContext` has been removed, and
+`raw::oio::MultipartCopier::new` now takes `executor: Executor` and
+`capability: Capability` as explicit parameters instead of a single
+`impl IntoMultipartCopyContext` argument. Pass `executor` and `capability`
+separately when constructing a `MultipartCopier`.
+
## Services
### Redb requires `redb` 5
diff --git a/core/core/src/layers/complete.rs b/core/core/src/layers/complete.rs
index 42b6f13499..696daf7ec7 100644
--- a/core/core/src/layers/complete.rs
+++ b/core/core/src/layers/complete.rs
@@ -34,18 +34,12 @@ impl std::fmt::Debug for CompleteLayer {
impl Layer for CompleteLayer {
fn apply_service(&self, inner: Servicer) -> Servicer {
- Arc::new(self.layer(inner))
- }
-}
-
-impl CompleteLayer {
- fn layer(&self, inner: Servicer) -> CompleteService {
- CompleteService { inner }
+ Arc::new(CompleteService { inner })
}
}
/// Provide complete wrapper for backend.
-pub struct CompleteService {
+struct CompleteService {
inner: Servicer,
}
@@ -127,8 +121,7 @@ impl Service for CompleteService {
}
async fn stat(&self, ctx: &OperationContext, path: &str, args: OpStat) ->
Result<RpStat> {
- let metadata = self.inner.stat(ctx, path, args).await?.into_metadata();
- Ok(RpStat::new(metadata))
+ self.inner.stat(ctx, path, args).await
}
fn delete(&self, ctx: &OperationContext) -> Result<Self::Deleter> {
@@ -150,7 +143,7 @@ impl Service for CompleteService {
}
}
-pub struct CompleteCopier {
+struct CompleteCopier {
inner: oio::Copier,
source_content_length_hint: Option<u64>,
copied: Option<u64>,
@@ -218,7 +211,7 @@ impl oio::Copy for CompleteCopier {
}
}
-pub struct CompleteLister {
+struct CompleteLister {
inner: oio::Lister,
ctx: OperationContext,
srv: Servicer,
@@ -279,12 +272,12 @@ impl oio::List for CompleteLister {
}
}
-pub struct CompleteReader<R> {
+struct CompleteReader<R> {
inner: R,
}
impl<R> CompleteReader<R> {
- pub fn new(inner: R) -> Self {
+ fn new(inner: R) -> Self {
Self { inner }
}
}
@@ -425,14 +418,14 @@ impl State {
}
}
-pub struct CompleteWriter {
+struct CompleteWriter {
append: bool,
size: u64,
state: State,
}
impl CompleteWriter {
- pub fn new(inner: oio::Writer, append: bool) -> CompleteWriter {
+ fn new(inner: oio::Writer, append: bool) -> CompleteWriter {
CompleteWriter {
append,
size: 0,
diff --git a/core/core/src/raw/oio/copy/multipart_copy.rs
b/core/core/src/raw/oio/copy/multipart_copy.rs
index b14f4d11ab..c78a0bab56 100644
--- a/core/core/src/raw/oio/copy/multipart_copy.rs
+++ b/core/core/src/raw/oio/copy/multipart_copy.rs
@@ -75,24 +75,6 @@ struct CopyInput<C: MultipartCopy> {
range: BytesRange,
}
-/// Build executor and capability inputs for [`MultipartCopier`].
-pub trait IntoMultipartCopyContext {
- /// Convert into executor and capability.
- fn into_multipart_copy_context(self) -> (Executor, Capability);
-}
-
-impl IntoMultipartCopyContext for Executor {
- fn into_multipart_copy_context(self) -> (Executor, Capability) {
- (self, Capability::default())
- }
-}
-
-impl IntoMultipartCopyContext for (Executor, Capability) {
- fn into_multipart_copy_context(self) -> (Executor, Capability) {
- self
- }
-}
-
struct CopiedPart {
part: MultipartPart,
size: u64,
@@ -131,14 +113,14 @@ pub struct MultipartCopier<C: MultipartCopy> {
impl<C: MultipartCopy> MultipartCopier<C> {
/// Create a new MultipartCopier.
pub fn new(
- context: impl IntoMultipartCopyContext,
+ executor: Executor,
+ capability: Capability,
inner: C,
source_content_length_hint: Option<u64>,
copy_once_threshold: u64,
part_size: u64,
concurrent: usize,
) -> Self {
- let (executor, capability) = context.into_multipart_copy_context();
let copier = Arc::new(inner);
let concurrent = concurrent.max(1);
@@ -497,8 +479,15 @@ mod tests {
#[tokio::test]
async fn test_content_length_hint_skips_source_metadata() -> Result<()> {
let inner = TestCopy::new(8);
- let mut copier =
- MultipartCopier::new(crate::test_executor(), inner.clone(),
Some(8), 8, 8, 1);
+ let mut copier = MultipartCopier::new(
+ crate::test_executor(),
+ Capability::default(),
+ inner.clone(),
+ Some(8),
+ 8,
+ 8,
+ 1,
+ );
let metadata = copier.close().await?;
assert_eq!(inner.source_metadata_calls.load(Ordering::Relaxed), 0);
@@ -511,7 +500,15 @@ mod tests {
#[tokio::test]
async fn test_missing_content_length_hint_loads_source_metadata() ->
Result<()> {
let inner = TestCopy::new(8);
- let mut copier = MultipartCopier::new(crate::test_executor(),
inner.clone(), None, 8, 8, 1);
+ let mut copier = MultipartCopier::new(
+ crate::test_executor(),
+ Capability::default(),
+ inner.clone(),
+ None,
+ 8,
+ 8,
+ 1,
+ );
let metadata = copier.close().await?;
assert_eq!(inner.source_metadata_calls.load(Ordering::Relaxed), 1);
@@ -532,7 +529,8 @@ mod tests {
// source_size=10, part_size=1, copy_once_threshold=0 -> 10 parts
needed, only 2 allowed.
let inner = TestCopy::new(10);
let mut copier = MultipartCopier::new(
- /*context=*/ (crate::test_executor(), capability),
+ /*executor=*/ crate::test_executor(),
+ /*capability=*/ capability,
/*inner=*/ inner.clone(),
/*source_content_length_hint=*/ Some(10),
/*copy_once_threshold=*/ 0,
@@ -632,6 +630,7 @@ mod tests {
let state = inner.state.clone();
let mut copier = MultipartCopier::new(
crate::test_executor(),
+ Capability::default(),
inner,
Some(8),
/*copy_once_threshold=*/ 0,
@@ -658,6 +657,7 @@ mod tests {
let state = inner.state.clone();
let mut copier = MultipartCopier::new(
crate::test_executor(),
+ Capability::default(),
inner,
Some(8),
/*copy_once_threshold=*/ 0,
@@ -697,6 +697,7 @@ mod tests {
let inner = TestCopy::new(8);
let mut copier = MultipartCopier::new(
crate::test_executor(),
+ Capability::default(),
inner.clone(),
Some(8),
/*copy_once_threshold=*/ 0,
@@ -731,6 +732,7 @@ mod tests {
let inner = TestCopy::new(8);
let mut copier = MultipartCopier::new(
crate::test_executor(),
+ Capability::default(),
inner.clone(),
Some(8),
/*copy_once_threshold=*/ 0,
@@ -764,6 +766,7 @@ mod tests {
let inner = TestCopy::with_abort_failures(8, 1);
let mut copier = MultipartCopier::new(
crate::test_executor(),
+ Capability::default(),
inner.clone(),
Some(8),
/*copy_once_threshold=*/ 0,
@@ -813,6 +816,7 @@ mod tests {
let inner = TestCopy::new(8);
let mut copier = MultipartCopier::new(
crate::test_executor(),
+ Capability::default(),
inner.clone(),
Some(8),
/*copy_once_threshold=*/ 0,
diff --git a/core/services/s3/src/copier.rs b/core/services/s3/src/copier.rs
index 45f710c513..acebd6b39e 100644
--- a/core/services/s3/src/copier.rs
+++ b/core/services/s3/src/copier.rs
@@ -68,7 +68,8 @@ pub fn new_s3_copier(
let concurrent = args.concurrent();
Ok(oio::MultipartCopier::new(
- (ctx.executor().clone(), capability),
+ ctx.executor().clone(),
+ capability,
S3Copier {
core,
ctx: ctx.clone(),
diff --git a/core/services/tos/src/copier.rs b/core/services/tos/src/copier.rs
index 261112f413..2e6735d5d4 100644
--- a/core/services/tos/src/copier.rs
+++ b/core/services/tos/src/copier.rs
@@ -63,7 +63,8 @@ pub fn new_tos_copier(
let concurrent = args.concurrent();
Ok(oio::MultipartCopier::new(
- (ctx.executor().clone(), capability),
+ ctx.executor().clone(),
+ capability,
TosCopier {
core,
ctx: ctx.clone(),