Skip to content

Commit d899d99

Browse files
authored
feat: collects pieces from multiple parents with load balancing strategy (#1173)
* feat: collects pieces from multiple parents with load balancing strategy Signed-off-by: Gaius <gaius.qi@gmail.com> * feat: update Signed-off-by: Gaius <gaius.qi@gmail.com> * feat: update Signed-off-by: Gaius <gaius.qi@gmail.com> * feat: update Signed-off-by: Gaius <gaius.qi@gmail.com> --------- Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 7f5b517 commit d899d99

File tree

6 files changed

+148
-77
lines changed

6 files changed

+148
-77
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ members = [
1212
]
1313

1414
[workspace.package]
15-
version = "0.2.33"
15+
version = "0.2.34"
1616
authors = ["The Dragonfly Developers"]
1717
homepage = "https://d7y.io/"
1818
repository = "https://github.com/dragonflyoss/client.git"
@@ -22,13 +22,13 @@ readme = "README.md"
2222
edition = "2021"
2323

2424
[workspace.dependencies]
25-
dragonfly-client = { path = "dragonfly-client", version = "0.2.33" }
26-
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.2.33" }
27-
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.2.33" }
28-
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.2.33" }
29-
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.2.33" }
30-
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.2.33" }
31-
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.2.33" }
25+
dragonfly-client = { path = "dragonfly-client", version = "0.2.34" }
26+
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.2.34" }
27+
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.2.34" }
28+
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.2.34" }
29+
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.2.34" }
30+
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.2.34" }
31+
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.2.34" }
3232
dragonfly-api = "=2.1.39"
3333
thiserror = "2.0"
3434
futures = "0.3.31"

dragonfly-client/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ http-body-util = "0.1.3"
8484
termion = "4.0.5"
8585
tabled = "0.19.0"
8686
path-absolutize = "3.1.1"
87+
dashmap = "6.1.0"
88+
fastrand = "2.3.0"
8789

8890
[dev-dependencies]
8991
tempfile.workspace = true

dragonfly-client/src/grpc/dfdaemon_download.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ impl DfdaemonDownloadServer {
133133
// Initialize health reporter.
134134
let (mut health_reporter, health_service) = tonic_health::server::health_reporter();
135135

136-
// Set the serving status of the download grpc server.
137-
health_reporter
138-
.set_serving::<DfdaemonDownloadGRPCServer<DfdaemonDownloadServerHandler>>()
139-
.await;
140-
141136
// Start download grpc server with unix domain socket.
142137
fs::create_dir_all(self.socket_path.parent().unwrap()).await?;
143138
fs::remove_file(self.socket_path.clone())
@@ -175,6 +170,12 @@ impl DfdaemonDownloadServer {
175170
// Notify the download grpc server is started.
176171
_ = grpc_server_started_barrier.wait() => {
177172
info!("download server is ready to start");
173+
174+
health_reporter
175+
.set_serving::<DfdaemonDownloadGRPCServer<DfdaemonDownloadServerHandler>>()
176+
.await;
177+
178+
info!("download server's health status set to serving");
178179
}
179180
// Wait for shutdown signal.
180181
_ = shutdown.recv() => {

dragonfly-client/src/grpc/dfdaemon_upload.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ impl DfdaemonUploadServer {
143143
// Initialize health reporter.
144144
let (mut health_reporter, health_service) = tonic_health::server::health_reporter();
145145

146-
// Set the serving status of the upload grpc server.
147-
health_reporter
148-
.set_serving::<DfdaemonUploadGRPCServer<DfdaemonUploadServerHandler>>()
149-
.await;
150-
151146
// TODO(Gaius): RateLimitLayer is not implemented Clone, so we can't use it here.
152147
// Only use the LoadShed layer and the ConcurrencyLimit layer.
153148
let rate_limit_layer = ServiceBuilder::new()
@@ -180,7 +175,13 @@ impl DfdaemonUploadServer {
180175
tokio::select! {
181176
// Notify the upload grpc server is started.
182177
_ = grpc_server_started_barrier.wait() => {
183-
info!("upload server is ready");
178+
info!("upload server is ready to start");
179+
180+
health_reporter
181+
.set_serving::<DfdaemonUploadGRPCServer<DfdaemonUploadServerHandler>>()
182+
.await;
183+
184+
info!("upload server's health status set to serving");
184185
}
185186
// Wait for shutdown signal.
186187
_ = shutdown.recv() => {

0 commit comments

Comments
 (0)