Skip to content

Commit 7d33221

Browse files
authored
Feature/bbr (#1735)
* fix: move BBR duration fields to workspace dep and fix serde Signed-off-by: Gaius <gaius.qi@gmail.com> * build: bump workspace version from 1.2.16 to 1.2.17 Signed-off-by: Gaius <gaius.qi@gmail.com> --------- Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 01d0d11 commit 7d33221

File tree

8 files changed

+29
-25
lines changed

8 files changed

+29
-25
lines changed

Cargo.lock

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ members = [
1313
]
1414

1515
[workspace.package]
16-
version = "1.2.16"
16+
version = "1.2.17"
1717
authors = ["The Dragonfly Developers"]
1818
homepage = "https://d7y.io/"
1919
repository = "https://github.com/dragonflyoss/client.git"
@@ -23,14 +23,14 @@ readme = "README.md"
2323
edition = "2021"
2424

2525
[workspace.dependencies]
26-
dragonfly-client = { path = "dragonfly-client", version = "1.2.16" }
27-
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.2.16" }
28-
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.2.16" }
29-
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.2.16" }
30-
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.2.16" }
31-
dragonfly-client-metric = { path = "dragonfly-client-metric", version = "1.2.16" }
32-
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.2.16" }
33-
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.2.16" }
26+
dragonfly-client = { path = "dragonfly-client", version = "1.2.17" }
27+
dragonfly-client-core = { path = "dragonfly-client-core", version = "1.2.17" }
28+
dragonfly-client-config = { path = "dragonfly-client-config", version = "1.2.17" }
29+
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "1.2.17" }
30+
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "1.2.17" }
31+
dragonfly-client-metric = { path = "dragonfly-client-metric", version = "1.2.17" }
32+
dragonfly-client-util = { path = "dragonfly-client-util", version = "1.2.17" }
33+
dragonfly-client-init = { path = "dragonfly-client-init", version = "1.2.17" }
3434
dragonfly-api = "=2.2.26"
3535
thiserror = "2.0"
3636
futures = "0.3.32"
@@ -119,6 +119,7 @@ fastrand = "2.3.0"
119119
cgroups-rs = "0.5"
120120
num_cpus = "1.17"
121121
async-trait = "0.1"
122+
humantime-serde = "1.1.1"
122123

123124
# TODO(Gaius): Remove the git dependency after the next release of mocktail, refer to https://github.com/IBM/mocktail/issues/65.
124125
mocktail = { version = "0.3.0", git = "https://github.com/IBM/mocktail", rev = "860e75e171a8eb818083813dbeed4401d1a40b3b" }

dragonfly-client-config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ rcgen.workspace = true
3333
reqwest.workspace = true
3434
hostname.workspace = true
3535
lazy_static.workspace = true
36+
humantime-serde.workspace = true
3637
home = "0.5.11"
37-
humantime-serde = "1.1.1"
3838
http-serde = "2.1.1"

dragonfly-client-util/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ dashmap.workspace = true
4848
reqwest-tracing.workspace = true
4949
reqwest-middleware.workspace = true
5050
num_cpus.workspace = true
51+
humantime-serde.workspace = true
5152
rustix = { version = "1.1.3", features = ["fs"] }
5253
base64 = "0.22.1"
5354
pnet = "0.35.0"

dragonfly-client-util/src/ratelimiter/bbr.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub struct BBRConfig {
101101
pub bucket_count: u32,
102102

103103
/// Duration of each time bucket (e.g., 200ms).
104-
#[serde(default = "default_bucket_interval")]
104+
#[serde(default = "default_bucket_interval", with = "humantime_serde")]
105105
pub bucket_interval: Duration,
106106

107107
/// CPU usage percentage threshold (0–100) above which the system is
@@ -116,10 +116,11 @@ pub struct BBRConfig {
116116

117117
/// Duration to continue shedding incoming requests after the first drop
118118
/// event, preventing rapid oscillation between shedding and accepting.
119-
#[serde(default = "default_shed_cooldown")]
119+
#[serde(default = "default_shed_cooldown", with = "humantime_serde")]
120120
pub shed_cooldown: Duration,
121121

122122
/// How often the background task collects CPU/memory usage metrics.
123+
#[serde(default = "default_collect_interval", with = "humantime_serde")]
123124
pub collect_interval: Duration,
124125
}
125126

dragonfly-client/src/grpc/dfdaemon_download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl DfdaemonDownloadServer {
203203
ServiceBuilder::new()
204204
.map_err(|err: Box<dyn std::error::Error + Send + Sync>| {
205205
if err.is::<Overloaded>() {
206-
Status::resource_exhausted("Server is overloaded, please retry later")
206+
Status::resource_exhausted("server is overloaded, please retry later")
207207
} else {
208208
Status::internal(err.to_string())
209209
}

dragonfly-client/src/grpc/dfdaemon_upload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl DfdaemonUploadServer {
189189
ServiceBuilder::new()
190190
.map_err(|err: Box<dyn std::error::Error + Send + Sync>| {
191191
if err.is::<Overloaded>() {
192-
Status::resource_exhausted("Server is overloaded, please retry later")
192+
Status::resource_exhausted("server is overloaded, please retry later")
193193
} else {
194194
Status::internal(err.to_string())
195195
}

dragonfly-client/src/grpc/middleware.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ where
111111
/// tracking and response time measurement.
112112
fn call(&mut self, req: Request<Body>) -> Self::Future {
113113
let bbr = self.bbr.clone();
114-
let mut inner = self.inner.clone();
115-
114+
let inner_clone = self.inner.clone();
115+
let mut inner = std::mem::replace(&mut self.inner, inner_clone);
116116
Box::pin(async move {
117117
// Try to acquire a BBR permit. If the system is overloaded,
118118
// the permit will be None and we reject the request.

0 commit comments

Comments
 (0)