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 1b300160e refactor: Split tail-cut layer to new crate (#6968)
1b300160e is described below
commit 1b300160e817493c0587b82ed1f22c63688bda9d
Author: Qinxuan Chen <[email protected]>
AuthorDate: Thu Dec 11 15:43:25 2025 +0800
refactor: Split tail-cut layer to new crate (#6968)
---
core/Cargo.lock | 9 +++++
core/Cargo.toml | 2 ++
core/core/src/layers/mod.rs | 4 ---
core/layers/tail-cut/Cargo.toml | 39 ++++++++++++++++++++++
.../tail_cut.rs => layers/tail-cut/src/lib.rs} | 25 ++++++++------
core/src/lib.rs | 2 ++
6 files changed, 66 insertions(+), 15 deletions(-)
diff --git a/core/Cargo.lock b/core/Cargo.lock
index 5486b8171..c9b72cd15 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5491,6 +5491,7 @@ dependencies = [
"opendal-layer-otelmetrics",
"opendal-layer-prometheus",
"opendal-layer-prometheus-client",
+ "opendal-layer-tail-cut",
"opendal-layer-tracing",
"opendal-service-aliyun-drive",
"opendal-service-azblob",
@@ -5750,6 +5751,14 @@ dependencies = [
"prometheus-client",
]
+[[package]]
+name = "opendal-layer-tail-cut"
+version = "0.55.0"
+dependencies = [
+ "opendal-core",
+ "tokio",
+]
+
[[package]]
name = "opendal-layer-tracing"
version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 4f845548b..5b71be1b5 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -99,6 +99,7 @@ layers-otel-metrics = ["dep:opendal-layer-otelmetrics"]
layers-otel-trace = ["opendal-core/layers-otel-trace"]
layers-prometheus = ["dep:opendal-layer-prometheus"]
layers-prometheus-client = ["dep:opendal-layer-prometheus-client"]
+layers-tail-cut = ["dep:opendal-layer-tail-cut"]
layers-throttle = ["opendal-core/layers-throttle"]
layers-tracing = ["dep:opendal-layer-tracing"]
reqwest-rustls-tls = ["opendal-core/reqwest-rustls-tls"]
@@ -196,6 +197,7 @@ opendal-layer-mime-guess = { path = "layers/mime-guess",
version = "0.55.0", opt
opendal-layer-otelmetrics = { path = "layers/otelmetrics", version = "0.55.0",
optional = true, default-features = false }
opendal-layer-prometheus = { path = "layers/prometheus", version = "0.55.0",
optional = true, default-features = false }
opendal-layer-prometheus-client = { path = "layers/prometheus-client", version
= "0.55.0", optional = true, default-features = false }
+opendal-layer-tail-cut = { path = "layers/tail-cut", version = "0.55.0",
optional = true, default-features = false }
opendal-layer-fastmetrics = { path = "layers/fastmetrics", version = "0.55.0",
optional = true, default-features = false }
opendal-layer-tracing = { path = "layers/tracing", version = "0.55.0",
optional = true, default-features = false }
opendal-service-aliyun-drive = { path = "services/aliyun-drive", version =
"0.55.0", optional = true, default-features = false }
diff --git a/core/core/src/layers/mod.rs b/core/core/src/layers/mod.rs
index 1de885a36..d65bda911 100644
--- a/core/core/src/layers/mod.rs
+++ b/core/core/src/layers/mod.rs
@@ -51,10 +51,6 @@ mod retry;
pub use self::retry::RetryInterceptor;
pub use self::retry::RetryLayer;
-mod tail_cut;
-pub use self::tail_cut::TailCutLayer;
-pub use self::tail_cut::TailCutLayerBuilder;
-
#[cfg(feature = "layers-fastrace")]
mod fastrace;
#[cfg(feature = "layers-fastrace")]
diff --git a/core/layers/tail-cut/Cargo.toml b/core/layers/tail-cut/Cargo.toml
new file mode 100644
index 000000000..6e67b2739
--- /dev/null
+++ b/core/layers/tail-cut/Cargo.toml
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+description = "Apache OpenDAL tail-cut layer"
+name = "opendal-layer-tail-cut"
+
+authors = { workspace = true }
+edition = { workspace = true }
+homepage = { workspace = true }
+license = { workspace = true }
+repository = { workspace = true }
+rust-version = { workspace = true }
+version = { workspace = true }
+
+[package.metadata.docs.rs]
+all-features = true
+
+[dependencies]
+opendal-core = { path = "../../core", version = "0.55.0", default-features =
false }
+tokio = { workspace = true, features = ["time"] }
+
+[dev-dependencies]
+opendal-core = { path = "../../core", version = "0.55.0" }
+tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
diff --git a/core/core/src/layers/tail_cut.rs b/core/layers/tail-cut/src/lib.rs
similarity index 98%
rename from core/core/src/layers/tail_cut.rs
rename to core/layers/tail-cut/src/lib.rs
index ae5189d25..3ecaedbaa 100644
--- a/core/core/src/layers/tail_cut.rs
+++ b/core/layers/tail-cut/src/lib.rs
@@ -20,8 +20,8 @@ use std::fmt::Formatter;
use std::sync::Arc;
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
/// Builder for TailCutLayer.
///
@@ -31,12 +31,13 @@ use crate::*;
/// # Examples
///
/// ```no_run
-/// use opendal_core::layers::TailCutLayer;
-/// use std::time::Duration;
+/// # use std::time::Duration;
+/// #
/// # use opendal_core::services;
/// # use opendal_core::Operator;
/// # use opendal_core::Result;
-///
+/// # use opendal_layer_tail_cut::TailCutLayer;
+/// #
/// # fn main() -> Result<()> {
/// let layer = TailCutLayer::builder()
/// .percentile(95)
@@ -174,12 +175,13 @@ impl TailCutLayerBuilder {
/// # Examples
///
/// ```no_run
- /// use opendal_core::layers::TailCutLayer;
- /// use std::time::Duration;
+ /// # use std::time::Duration;
+ /// #
/// # use opendal_core::services;
/// # use opendal_core::Operator;
/// # use opendal_core::Result;
- ///
+ /// # use opendal_layer_tail_cut::TailCutLayer;
+ /// #
/// # fn main() -> Result<()> {
/// let layer = TailCutLayer::builder()
/// .percentile(95)
@@ -235,12 +237,13 @@ struct TailCutConfig {
/// # Examples
///
/// ```no_run
-/// use opendal_core::layers::TailCutLayer;
-/// use std::time::Duration;
+/// # use std::time::Duration;
+/// #
/// # use opendal_core::services;
/// # use opendal_core::Operator;
/// # use opendal_core::Result;
-///
+/// # use opendal_layer_tail_cut::TailCutLayer;
+/// #
/// # fn main() -> Result<()> {
/// let layer = TailCutLayer::builder()
/// .percentile(95)
diff --git a/core/src/lib.rs b/core/src/lib.rs
index c15699a84..ce258f107 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -68,6 +68,8 @@ pub mod layers {
pub use opendal_layer_prometheus::*;
#[cfg(feature = "layers-prometheus-client")]
pub use opendal_layer_prometheus_client::*;
+ #[cfg(feature = "layers-tail-cut")]
+ pub use opendal_layer_tail_cut::*;
#[cfg(feature = "layers-tracing")]
pub use opendal_layer_tracing::*;
}