This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 6980cd150 build(dep): Bump governor from 0.5.1 to 0.6.0 (#3761)
6980cd150 is described below
commit 6980cd15007c9a2ae8422cbc0750c818e178abf2
Author: G-XD <[email protected]>
AuthorDate: Sat Dec 16 09:10:31 2023 +0800
build(dep): Bump governor from 0.5.1 to 0.6.0 (#3761)
---
Cargo.lock | 39 ++++-----------------------------------
core/Cargo.toml | 2 +-
core/src/layers/throttle.rs | 37 ++++++++++++++++---------------------
3 files changed, 21 insertions(+), 57 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index e9d4cb1fc..47be8ca84 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2966,9 +2966,9 @@ dependencies = [
[[package]]
name = "governor"
-version = "0.5.1"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c390a940a5d157878dd057c78680a33ce3415bcd05b4799509ea44210914b4d5"
+checksum = "821239e5672ff23e2a7060901fa622950bbd80b649cdaadd78d1c1767ed14eb4"
dependencies = [
"cfg-if",
"dashmap",
@@ -2977,7 +2977,7 @@ dependencies = [
"no-std-compat",
"nonzero_ext",
"parking_lot 0.12.1",
- "quanta 0.9.3",
+ "quanta",
"rand 0.8.5",
"smallvec",
]
@@ -3856,15 +3856,6 @@ dependencies = [
"linked-hash-map",
]
-[[package]]
-name = "mach"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
-dependencies = [
- "libc",
-]
-
[[package]]
name = "mach2"
version = "0.4.1"
@@ -4183,7 +4174,7 @@ dependencies = [
"futures-util",
"once_cell",
"parking_lot 0.12.1",
- "quanta 0.11.1",
+ "quanta",
"rustc_version 0.4.0",
"skeptic",
"smallvec",
@@ -5848,22 +5839,6 @@ dependencies = [
"syn 2.0.39",
]
-[[package]]
-name = "quanta"
-version = "0.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20afe714292d5e879d8b12740aa223c6a88f118af41870e8b6196e39a02238a8"
-dependencies = [
- "crossbeam-utils",
- "libc",
- "mach",
- "once_cell",
- "raw-cpuid",
- "wasi 0.10.2+wasi-snapshot-preview1",
- "web-sys",
- "winapi",
-]
-
[[package]]
name = "quanta"
version = "0.11.1"
@@ -8161,12 +8136,6 @@ version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
-[[package]]
-name = "wasi"
-version = "0.10.2+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
-
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index fa177f7c6..301dc99e7 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -245,7 +245,7 @@ foundationdb = { version = "0.8.0", features = [
"embedded-fdb-include",
], optional = true }
futures = { version = "0.3", default-features = false, features = ["std"] }
-governor = { version = "0.5", optional = true, features = ["std"] }
+governor = { version = "0.6.0", optional = true, features = ["std"] }
hdrs = { version = "0.3.0", optional = true, features = ["async_file"] }
hrana-client-proto = { version = "0.2.1", optional = true }
http = "0.2.9"
diff --git a/core/src/layers/throttle.rs b/core/src/layers/throttle.rs
index d76428b39..ea3da1cdb 100644
--- a/core/src/layers/throttle.rs
+++ b/core/src/layers/throttle.rs
@@ -29,7 +29,6 @@ use governor::clock::DefaultClock;
use governor::middleware::NoOpMiddleware;
use governor::state::InMemoryState;
use governor::state::NotKeyed;
-use governor::NegativeMultiDecision;
use governor::Quota;
use governor::RateLimiter;
@@ -221,24 +220,22 @@ impl<R: oio::Write> oio::Write for ThrottleWrapper<R> {
loop {
match self.limiter.check_n(buf_length) {
- Ok(_) => return self.inner.poll_write(cx, bs),
- Err(negative) => match negative {
+ Ok(res) => match res {
+ Ok(_) => return self.inner.poll_write(cx, bs),
// the query is valid but the Decider can not accommodate
them.
- NegativeMultiDecision::BatchNonConforming(_, not_until) =>
{
+ Err(not_until) => {
let _ =
not_until.wait_time_from(DefaultClock::default().now());
// TODO: Should lock the limiter and wait for the
wait_time, or should let other small requests go first?
// FIXME: we should sleep here.
// tokio::time::sleep(wait_time).await;
}
- // the query was invalid as the rate limit parameters can
"never" accommodate the number of cells queried for.
- NegativeMultiDecision::InsufficientCapacity(_) => {
- return Poll::Ready(Err(Error::new(
- ErrorKind::RateLimited,
- "InsufficientCapacity due to burst size being
smaller than the request size",
- )))
- }
},
+ // the query was invalid as the rate limit parameters can
"never" accommodate the number of cells queried for.
+ Err(_) => return Poll::Ready(Err(Error::new(
+ ErrorKind::RateLimited,
+ "InsufficientCapacity due to burst size being smaller than
the request size",
+ ))),
}
}
}
@@ -258,21 +255,19 @@ impl<R: oio::BlockingWrite> oio::BlockingWrite for
ThrottleWrapper<R> {
loop {
match self.limiter.check_n(buf_length) {
- Ok(_) => return self.inner.write(bs),
- Err(negative) => match negative {
+ Ok(res) => match res {
+ Ok(_) => return self.inner.write(bs),
// the query is valid but the Decider can not accommodate
them.
- NegativeMultiDecision::BatchNonConforming(_, not_until) =>
{
+ Err(not_until) => {
let wait_time =
not_until.wait_time_from(DefaultClock::default().now());
thread::sleep(wait_time);
}
- // the query was invalid as the rate limit parameters can
"never" accommodate the number of cells queried for.
- NegativeMultiDecision::InsufficientCapacity(_) => {
- return Err(Error::new(
- ErrorKind::RateLimited,
- "InsufficientCapacity due to burst size being
smaller than the request size",
- ))
- }
},
+ // the query was invalid as the rate limit parameters can
"never" accommodate the number of cells queried for.
+ Err(_) => return Err(Error::new(
+ ErrorKind::RateLimited,
+ "InsufficientCapacity due to burst size being smaller than
the request size",
+ )),
}
}
}