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 ff67b53af refactor: split throttle layer to new crate (#6980)
ff67b53af is described below

commit ff67b53af491567e008103b706647ec02766f908
Author: Eric Zhao <[email protected]>
AuthorDate: Fri Dec 12 19:24:14 2025 +0800

    refactor: split throttle layer to new crate (#6980)
    
    [core split] Layer: throttle
---
 core/Cargo.lock                                    | 10 ++++++-
 core/Cargo.toml                                    |  9 ++----
 core/core/Cargo.toml                               |  4 ---
 core/core/src/layers/mod.rs                        |  5 ----
 core/layers/throttle/Cargo.toml                    | 35 ++++++++++++++++++++++
 .../throttle.rs => layers/throttle/src/lib.rs}     |  6 ++--
 core/src/lib.rs                                    |  2 ++
 7 files changed, 52 insertions(+), 19 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index e326d6814..858a2d813 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5494,6 +5494,7 @@ dependencies = [
  "opendal-layer-prometheus",
  "opendal-layer-prometheus-client",
  "opendal-layer-tail-cut",
+ "opendal-layer-throttle",
  "opendal-layer-tracing",
  "opendal-service-aliyun-drive",
  "opendal-service-azblob",
@@ -5570,7 +5571,6 @@ dependencies = [
  "foundationdb",
  "futures",
  "getrandom 0.2.16",
- "governor",
  "hdfs-native",
  "hdrs",
  "hmac",
@@ -5783,6 +5783,14 @@ dependencies = [
  "tokio",
 ]
 
+[[package]]
+name = "opendal-layer-throttle"
+version = "0.55.0"
+dependencies = [
+ "governor",
+ "opendal-core",
+]
+
 [[package]]
 name = "opendal-layer-tracing"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 0450e8556..761a445f6 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -78,11 +78,7 @@ all-features = true
 
 [features]
 blocking = ["opendal-core/blocking"]
-default = [
-  "reqwest-rustls-tls",
-  "executors-tokio",
-  "services-memory",
-]
+default = ["reqwest-rustls-tls", "executors-tokio", "services-memory"]
 executors-tokio = ["opendal-core/executors-tokio"]
 internal-path-cache = ["opendal-core/internal-path-cache"]
 internal-tokio-rt = ["opendal-core/internal-tokio-rt"]
@@ -101,7 +97,7 @@ layers-otel-trace = ["dep:opendal-layer-oteltrace"]
 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-throttle = ["dep:opendal-layer-throttle"]
 layers-tracing = ["dep:opendal-layer-tracing"]
 reqwest-rustls-tls = ["opendal-core/reqwest-rustls-tls"]
 services-aliyun-drive = ["dep:opendal-service-aliyun-drive"]
@@ -203,6 +199,7 @@ opendal-layer-oteltrace = { path = "layers/oteltrace", 
version = "0.55.0", optio
 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-throttle = { path = "layers/throttle", 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 }
 opendal-service-azblob = { path = "services/azblob", version = "0.55.0", 
optional = true, default-features = false }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index b3ec4c05e..3c703649e 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -72,8 +72,6 @@ executors-tokio = ["tokio/rt"]
 
 # Enable layers chaos support
 layers-chaos = ["dep:rand"]
-# Enable layers throttle support.
-layers-throttle = ["dep:governor"]
 # Enable dtrace support.
 layers-dtrace = ["dep:probe"]
 
@@ -281,8 +279,6 @@ web-sys = { version = "0.3.77", optional = true, features = 
[
 ] }
 
 # Layers
-# for layers-throttle
-governor = { version = "0.10.1", optional = true, features = ["std"] }
 # for layers-dtrace
 probe = { version = "0.5.1", optional = true }
 
diff --git a/core/core/src/layers/mod.rs b/core/core/src/layers/mod.rs
index a4acf2c10..dcee92265 100644
--- a/core/core/src/layers/mod.rs
+++ b/core/core/src/layers/mod.rs
@@ -48,11 +48,6 @@ mod retry;
 pub use self::retry::RetryInterceptor;
 pub use self::retry::RetryLayer;
 
-#[cfg(feature = "layers-throttle")]
-mod throttle;
-#[cfg(feature = "layers-throttle")]
-pub use self::throttle::ThrottleLayer;
-
 #[cfg(all(target_os = "linux", feature = "layers-dtrace"))]
 mod dtrace;
 #[cfg(all(target_os = "linux", feature = "layers-dtrace"))]
diff --git a/core/layers/throttle/Cargo.toml b/core/layers/throttle/Cargo.toml
new file mode 100644
index 000000000..e4000c4c9
--- /dev/null
+++ b/core/layers/throttle/Cargo.toml
@@ -0,0 +1,35 @@
+# 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 throttle layer"
+name = "opendal-layer-throttle"
+
+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]
+governor = { version = "0.10.1", features = ["std"] }
+opendal-core = { path = "../../core", version = "0.55.0", default-features = 
false }
diff --git a/core/core/src/layers/throttle.rs b/core/layers/throttle/src/lib.rs
similarity index 98%
rename from core/core/src/layers/throttle.rs
rename to core/layers/throttle/src/lib.rs
index 13f8e6e16..2127855f7 100644
--- a/core/core/src/layers/throttle.rs
+++ b/core/layers/throttle/src/lib.rs
@@ -25,8 +25,8 @@ use governor::middleware::NoOpMiddleware;
 use governor::state::InMemoryState;
 use governor::state::NotKeyed;
 
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 /// Add a bandwidth rate limiter to the underlying services.
 ///
@@ -49,7 +49,7 @@ use crate::*;
 /// This example limits bandwidth to 10 KiB/s and burst size to 10 MiB.
 ///
 /// ```no_run
-/// # use opendal_core::layers::ThrottleLayer;
+/// # use opendal_layer_throttle::ThrottleLayer;
 /// # use opendal_core::services;
 /// # use opendal_core::Operator;
 /// # use opendal_core::Result;
diff --git a/core/src/lib.rs b/core/src/lib.rs
index c0ee7a289..f553e9e2b 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -86,6 +86,8 @@ pub mod layers {
     pub use opendal_layer_prometheus_client::*;
     #[cfg(feature = "layers-tail-cut")]
     pub use opendal_layer_tail_cut::*;
+    #[cfg(feature = "layers-throttle")]
+    pub use opendal_layer_throttle::*;
     #[cfg(feature = "layers-tracing")]
     pub use opendal_layer_tracing::*;
 }

Reply via email to