This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch polish-details in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit f097a75102d14168b6cbf8abf6696f1966f1eca7 Author: Xuanwo <[email protected]> AuthorDate: Wed Sep 13 16:05:12 2023 +0800 fix: Don't apply blocking layer when service support blocking Signed-off-by: Xuanwo <[email protected]> --- core/src/layers/blocking.rs | 8 +++----- core/tests/behavior/utils.rs | 9 +++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/layers/blocking.rs b/core/src/layers/blocking.rs index 7dd2d189c..4b641c986 100644 --- a/core/src/layers/blocking.rs +++ b/core/src/layers/blocking.rs @@ -25,13 +25,11 @@ use crate::raw::oio::ReadExt; use crate::raw::*; use crate::*; -/// Add blocking API support for every operations. +/// Add blocking API support for non-blocking services. /// -/// # Blocking API +/// # Notes /// -/// - This layer is auto-added to the operator if it's accessor doesn't support blocking APIs. -/// -/// Tracking issue: #2678 +/// Please only enable this layer when underlying services are not blocking. #[derive(Debug, Clone)] pub struct BlockingLayer { handle: Handle, diff --git a/core/tests/behavior/utils.rs b/core/tests/behavior/utils.rs index 3f197869e..c3bf5eb2f 100644 --- a/core/tests/behavior/utils.rs +++ b/core/tests/behavior/utils.rs @@ -83,13 +83,18 @@ pub fn init_service<B: Builder>() -> Option<Operator> { }; let _guard = RUNTIME.enter(); - let op = op - .layer(BlockingLayer::create().expect("blocking layer must be created")) + + let mut op = op .layer(LoggingLayer::default().with_backtrace_output(true)) .layer(TimeoutLayer::new()) .layer(RetryLayer::new()) .finish(); + if !op.info().full_capability().blocking { + let _guard = RUNTIME.enter(); + op = op.layer(BlockingLayer::create().expect("blocking layer must be created")) + } + Some(op) }
