diff --git a/Cargo.lock b/Cargo.lock index 50bea240..33561e68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,18 +441,17 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.11", - "http-body 0.4.6", - "hyper 0.14.28", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "itoa", "matchit", "memchr", @@ -461,7 +460,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper", + "sync_wrapper 1.0.1", "tower", "tower-layer", "tower-service", @@ -469,17 +468,20 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.11", - "http-body 0.4.6", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", ] @@ -1103,12 +1105,12 @@ dependencies = [ [[package]] name = "dragonfly-api" -version = "2.0.142" +version = "2.0.143" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0258d872ecbd38b4b2afe77828e71575bf5d7445a3b7332ea983bff9ec88862b" +checksum = "bff3ba3f7d411a6aa67e8c812f94e927ed06b782a2f44aa4dbe3df99593da5b7" dependencies = [ - "prost 0.11.9", - "prost-types 0.13.1", + "prost 0.13.1", + "prost-types", "prost-wkt-types", "serde", "tokio", @@ -1118,7 +1120,7 @@ dependencies = [ [[package]] name = "dragonfly-client" -version = "0.1.94" +version = "0.1.95" dependencies = [ "anyhow", "blake3", @@ -1188,7 +1190,7 @@ dependencies = [ [[package]] name = "dragonfly-client-backend" -version = "0.1.94" +version = "0.1.95" dependencies = [ "dragonfly-api", "dragonfly-client-core", @@ -1210,7 +1212,7 @@ dependencies = [ [[package]] name = "dragonfly-client-config" -version = "0.1.94" +version = "0.1.95" dependencies = [ "bytesize", "bytesize-serde", @@ -1231,7 +1233,7 @@ dependencies = [ [[package]] name = "dragonfly-client-core" -version = "0.1.94" +version = "0.1.95" dependencies = [ "hyper 1.4.0", "hyper-util", @@ -1246,7 +1248,7 @@ dependencies = [ [[package]] name = "dragonfly-client-init" -version = "0.1.94" +version = "0.1.95" dependencies = [ "anyhow", "clap", @@ -1262,7 +1264,7 @@ dependencies = [ [[package]] name = "dragonfly-client-storage" -version = "0.1.94" +version = "0.1.95" dependencies = [ "base16ct", "chrono", @@ -1286,7 +1288,7 @@ dependencies = [ [[package]] name = "dragonfly-client-util" -version = "0.1.94" +version = "0.1.95" dependencies = [ "base16ct", "blake3", @@ -1756,7 +1758,7 @@ dependencies = [ [[package]] name = "hdfs" -version = "0.1.94" +version = "0.1.95" dependencies = [ "dragonfly-client-backend", "dragonfly-client-core", @@ -2024,14 +2026,15 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper 0.14.28", + "hyper 1.4.0", + "hyper-util", "pin-project-lite", "tokio", - "tokio-io-timeout", + "tower-service", ] [[package]] @@ -3349,12 +3352,12 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "prettyplease" -version = "0.1.25" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +checksum = "8d3928fb5db768cb86f891ff014f0144589297e3c6a1aba6ed7cecfdace270c7" dependencies = [ "proc-macro2", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] @@ -3452,24 +3455,23 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.9" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +checksum = "5bb182580f71dd070f88d01ce3de9f4da5021db7115d2e1c3605a754153b77c1" dependencies = [ "bytes", - "heck 0.4.1", - "itertools 0.10.5", - "lazy_static", + "heck 0.5.0", + "itertools 0.11.0", "log", "multimap", + "once_cell", "petgraph", "prettyplease", - "prost 0.11.9", - "prost-types 0.11.9", + "prost 0.13.1", + "prost-types", "regex", - "syn 1.0.109", + "syn 2.0.48", "tempfile", - "which", ] [[package]] @@ -3498,15 +3500,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "prost-types" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" -dependencies = [ - "prost 0.11.9", -] - [[package]] name = "prost-types" version = "0.13.1" @@ -3518,13 +3511,13 @@ dependencies = [ [[package]] name = "prost-wkt" -version = "0.4.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562788060bcf2bfabe055194bd991ed2442457661744c88e0a0828ff9a08c08b" +checksum = "a8d84e2bee181b04c2bac339f2bfe818c46a99750488cc6728ce4181d5aa8299" dependencies = [ "chrono", "inventory", - "prost 0.11.9", + "prost 0.13.1", "serde", "serde_derive", "serde_json", @@ -3533,27 +3526,27 @@ dependencies = [ [[package]] name = "prost-wkt-build" -version = "0.4.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4dca8bcead3b728a6a7da017cc95e7f4cb2320ec4f6896bc593a1c4700f7328" +checksum = "8a669d5acbe719010c6f62a64e6d7d88fdedc1fe46e419747949ecb6312e9b14" dependencies = [ - "heck 0.4.1", - "prost 0.11.9", + "heck 0.5.0", + "prost 0.13.1", "prost-build", - "prost-types 0.11.9", + "prost-types", "quote", ] [[package]] name = "prost-wkt-types" -version = "0.4.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2377c5680f2342871823045052e791b4487f7c90aae17e0feaee24cf59578a34" +checksum = "01ef068e9b82e654614b22e6b13699bd545b6c0e2e721736008b00b38aeb4f64" dependencies = [ "chrono", - "prost 0.11.9", + "prost 0.13.1", "prost-build", - "prost-types 0.11.9", + "prost-types", "prost-wkt", "prost-wkt-build", "regex", @@ -3858,7 +3851,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-native-tls", @@ -4475,6 +4468,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "synstructure" version = "0.12.6" @@ -4749,16 +4748,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.4.0" @@ -4867,25 +4856,27 @@ dependencies = [ [[package]] name = "tonic" -version = "0.9.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" +checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" dependencies = [ + "async-stream", "async-trait", "axum", - "base64 0.21.7", + "base64 0.22.1", "bytes", "flate2", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.11", - "http-body 0.4.6", - "hyper 0.14.28", + "h2 0.4.2", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.4.0", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", - "prost 0.11.9", + "prost 0.13.1", + "socket2 0.5.5", "tokio", "tokio-stream", "tower", @@ -4896,25 +4887,25 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.9.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" +checksum = "568392c5a2bd0020723e3f387891176aabafe36fd9fcd074ad309dfa0c8eb964" dependencies = [ "prettyplease", "proc-macro2", "prost-build", "quote", - "syn 1.0.109", + "syn 2.0.48", ] [[package]] name = "tonic-health" -version = "0.9.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080964d45894b90273d2b1dd755fdd114560db8636bb41cea615213c45043c4d" +checksum = "e1e10e6a96ee08b6ce443487d4368442d328d0e746f3681f81127f7dc41b4955" dependencies = [ "async-stream", - "prost 0.11.9", + "prost 0.13.1", "tokio", "tokio-stream", "tonic", @@ -4922,12 +4913,12 @@ dependencies = [ [[package]] name = "tonic-reflection" -version = "0.9.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0543d7092032041fbeac1f2c84304537553421a11a623c2301b12ef0264862c7" +checksum = "b742c83ad673e9ab5b4ce0981f7b9e8932be9d60e8682cbf9120494764dbc173" dependencies = [ - "prost 0.11.9", - "prost-types 0.11.9", + "prost 0.13.1", + "prost-types", "tokio", "tokio-stream", "tonic", @@ -5446,18 +5437,6 @@ dependencies = [ "rustls-pki-types", ] -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix 0.38.31", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index d937eed2..d3b241b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ ] [workspace.package] -version = "0.1.94" +version = "0.1.95" authors = ["The Dragonfly Developers"] homepage = "https://d7y.io/" repository = "https://github.com/dragonflyoss/client.git" @@ -22,15 +22,15 @@ readme = "README.md" edition = "2021" [workspace.dependencies] -dragonfly-client = { path = "dragonfly-client", version = "0.1.94" } -dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.94" } -dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.94" } -dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.94" } -dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.94" } -dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.94" } -dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.94" } +dragonfly-client = { path = "dragonfly-client", version = "0.1.95" } +dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.95" } +dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.95" } +dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.95" } +dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.95" } +dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.95" } +dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.95" } thiserror = "1.0" -dragonfly-api = "2.0.142" +dragonfly-api = "2.0.143" reqwest = { version = "0.12.4", features = ["stream", "native-tls", "default-tls", "rustls-tls"] } rcgen = { version = "0.12.1", features = ["x509-parser"] } hyper = { version = "1.4", features = ["full"] } @@ -59,7 +59,7 @@ serde = { version = "1.0", features = ["derive"] } serde_yaml = "0.9" serde_json = "1.0" http = "1" -tonic = { version = "0.9.2", features = ["gzip"] } +tonic = { version = "0.12.1", features = ["gzip"] } tokio = { version = "1.39.2", features = ["full"] } tokio-util = { version = "0.7.11", features = ["full"] } tokio-stream = "0.1.15" @@ -68,7 +68,7 @@ warp = "0.3.5" headers = "0.4.0" regex = "1.10.5" humantime = "2.1.0" -prost-wkt-types = "0.4" +prost-wkt-types = "0.6" chrono = { version = "0.4.35", features = ["serde", "clock"] } openssl = { version = "0.10", features = ["vendored"] } opendal = { version = "0.47.3", features = [ diff --git a/dragonfly-client/Cargo.toml b/dragonfly-client/Cargo.toml index 054ab000..0cb2dd6d 100644 --- a/dragonfly-client/Cargo.toml +++ b/dragonfly-client/Cargo.toml @@ -72,8 +72,8 @@ opentelemetry-jaeger = { version = "0.17.0", features = ["rt-tokio"] } pprof = { version = "0.13", features = ["flamegraph", "protobuf-codec"] } lazy_static = "1.5" prometheus = { version = "0.13", features = ["process"] } -tonic-health = "0.9.2" -tonic-reflection = "0.9.2" +tonic-health = "0.12.1" +tonic-reflection = "0.12.1" bytes = "1.6" sysinfo = "0.30.13" tower = "0.4.13" diff --git a/dragonfly-client/src/grpc/dfdaemon_download.rs b/dragonfly-client/src/grpc/dfdaemon_download.rs index dfd13d4a..d738dbbe 100644 --- a/dragonfly-client/src/grpc/dfdaemon_download.rs +++ b/dragonfly-client/src/grpc/dfdaemon_download.rs @@ -44,6 +44,7 @@ use dragonfly_client_util::{ digest::{calculate_file_hash, Algorithm}, http::{get_range, hashmap_to_reqwest_headermap, reqwest_headermap_to_hashmap}, }; +use hyper_util::rt::TokioIo; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::{Duration, Instant}; @@ -133,7 +134,6 @@ impl DfdaemonDownloadServer { Server::builder() .max_frame_size(super::MAX_FRAME_SIZE) .concurrency_limit_per_connection(super::CONCURRENCY_LIMIT_PER_CONNECTION) - .tcp_keepalive(Some(super::TCP_KEEPALIVE)) .add_service(reflection.clone()) .add_service(health_service) .add_service(self.service.clone()) @@ -369,7 +369,7 @@ impl DfdaemonDownload for DfdaemonDownloadServerHandler { .as_str(), download_clone.priority.to_string().as_str(), task_clone.content_length().unwrap_or_default(), - download_clone.range.clone(), + download_clone.range, start_time.elapsed(), ); @@ -391,7 +391,7 @@ impl DfdaemonDownload for DfdaemonDownloadServerHandler { .hard_link_or_copy( task_clone, Path::new(output_path.as_str()), - download_clone.range.clone(), + download_clone.range, ) .await { @@ -986,7 +986,12 @@ impl DfdaemonDownloadClient { let channel = Endpoint::try_from("http://[::]:50051") .unwrap() .connect_with_connector(service_fn(move |_: Uri| { - UnixStream::connect(socket_path.clone()) + let socket_path = socket_path.clone(); + async move { + Ok::<_, std::io::Error>(TokioIo::new( + UnixStream::connect(socket_path.clone()).await?, + )) + } })) .await .map_err(|err| { diff --git a/dragonfly-client/src/grpc/dfdaemon_upload.rs b/dragonfly-client/src/grpc/dfdaemon_upload.rs index 42e877ba..6976a511 100644 --- a/dragonfly-client/src/grpc/dfdaemon_upload.rs +++ b/dragonfly-client/src/grpc/dfdaemon_upload.rs @@ -121,7 +121,6 @@ impl DfdaemonUploadServer { Server::builder() .max_frame_size(super::MAX_FRAME_SIZE) .concurrency_limit_per_connection(super::CONCURRENCY_LIMIT_PER_CONNECTION) - .tcp_keepalive(Some(super::TCP_KEEPALIVE)) .add_service(reflection.clone()) .add_service(health_service) .add_service(self.service.clone()) @@ -354,7 +353,7 @@ impl DfdaemonUpload for DfdaemonUploadServerHandler { .as_str(), download_clone.priority.to_string().as_str(), task_clone.content_length().unwrap_or_default(), - download_clone.range.clone(), + download_clone.range, start_time.elapsed(), ); @@ -376,7 +375,7 @@ impl DfdaemonUpload for DfdaemonUploadServerHandler { .hard_link_or_copy( task_clone, Path::new(output_path.as_str()), - download_clone.range.clone(), + download_clone.range, ) .await { @@ -998,7 +997,6 @@ impl DfdaemonUploadClient { let channel = Channel::from_static(Box::leak(addr.clone().into_boxed_str())) .connect_timeout(super::CONNECT_TIMEOUT) .timeout(super::REQUEST_TIMEOUT) - .tcp_keepalive(Some(super::TCP_KEEPALIVE)) .connect() .await .map_err(|err| { diff --git a/dragonfly-client/src/grpc/health.rs b/dragonfly-client/src/grpc/health.rs index 89537c07..0a973e8d 100644 --- a/dragonfly-client/src/grpc/health.rs +++ b/dragonfly-client/src/grpc/health.rs @@ -18,6 +18,7 @@ use dragonfly_client_core::{ error::{ErrorType, OrErr}, Error, Result, }; +use hyper_util::rt::TokioIo; use std::path::PathBuf; use tokio::net::UnixStream; use tonic::transport::{Channel, Endpoint, Uri}; @@ -43,6 +44,8 @@ impl HealthClient { .connect_timeout(super::CONNECT_TIMEOUT) .timeout(super::REQUEST_TIMEOUT) .tcp_keepalive(Some(super::TCP_KEEPALIVE)) + .http2_keep_alive_interval(super::HTTP2_KEEP_ALIVE_INTERVAL) + .keep_alive_timeout(super::HTTP2_KEEP_ALIVE_TIMEOUT) .connect() .await .map_err(|err| { @@ -63,7 +66,12 @@ impl HealthClient { let channel = Endpoint::try_from("http://[::]:50051") .unwrap() .connect_with_connector(service_fn(move |_: Uri| { - UnixStream::connect(socket_path.clone()) + let socket_path = socket_path.clone(); + async move { + Ok::<_, std::io::Error>(TokioIo::new( + UnixStream::connect(socket_path.clone()).await?, + )) + } })) .await .map_err(|err| { diff --git a/dragonfly-client/src/grpc/manager.rs b/dragonfly-client/src/grpc/manager.rs index 0fdcd391..a7d8da73 100644 --- a/dragonfly-client/src/grpc/manager.rs +++ b/dragonfly-client/src/grpc/manager.rs @@ -74,6 +74,8 @@ impl ManagerClient { .connect_timeout(super::CONNECT_TIMEOUT) .timeout(super::REQUEST_TIMEOUT) .tcp_keepalive(Some(super::TCP_KEEPALIVE)) + .http2_keep_alive_interval(super::HTTP2_KEEP_ALIVE_INTERVAL) + .keep_alive_timeout(super::HTTP2_KEEP_ALIVE_TIMEOUT) .connect() .await .map_err(|err| { diff --git a/dragonfly-client/src/grpc/mod.rs b/dragonfly-client/src/grpc/mod.rs index 7394b71e..65386c41 100644 --- a/dragonfly-client/src/grpc/mod.rs +++ b/dragonfly-client/src/grpc/mod.rs @@ -41,7 +41,13 @@ pub const REQUEST_TIMEOUT: Duration = Duration::from_secs(10); pub const CONCURRENCY_LIMIT_PER_CONNECTION: usize = 8192; // TCP_KEEPALIVE is the keepalive duration for TCP connection. -pub const TCP_KEEPALIVE: Duration = Duration::from_secs(60); +pub const TCP_KEEPALIVE: Duration = Duration::from_secs(3600); + +// HTTP2_KEEP_ALIVE_INTERVAL is the interval for HTTP2 keep alive. +pub const HTTP2_KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(60); + +// HTTP2_KEEP_ALIVE_TIMEOUT is the timeout for HTTP2 keep alive. +pub const HTTP2_KEEP_ALIVE_TIMEOUT: Duration = Duration::from_secs(5); // MAX_FRAME_SIZE is the max frame size for GRPC, default is 12MB. pub const MAX_FRAME_SIZE: u32 = 12 * 1024 * 1024; diff --git a/dragonfly-client/src/grpc/scheduler.rs b/dragonfly-client/src/grpc/scheduler.rs index 0a874509..40074f85 100644 --- a/dragonfly-client/src/grpc/scheduler.rs +++ b/dragonfly-client/src/grpc/scheduler.rs @@ -174,7 +174,6 @@ impl SchedulerClient { .map_err(|_| Error::InvalidURI(addr.to_string()))? .connect_timeout(super::CONNECT_TIMEOUT) .timeout(super::REQUEST_TIMEOUT) - .tcp_keepalive(Some(super::TCP_KEEPALIVE)) .connect() .await .map_err(|err| { @@ -228,7 +227,6 @@ impl SchedulerClient { .map_err(|_| Error::InvalidURI(addr.to_string()))? .connect_timeout(super::CONNECT_TIMEOUT) .timeout(super::REQUEST_TIMEOUT) - .tcp_keepalive(Some(super::TCP_KEEPALIVE)) .connect() .await .map_err(|err| { @@ -287,7 +285,6 @@ impl SchedulerClient { .map_err(|_| Error::InvalidURI(addr.to_string()))? .connect_timeout(super::CONNECT_TIMEOUT) .timeout(super::REQUEST_TIMEOUT) - .tcp_keepalive(Some(super::TCP_KEEPALIVE)) .connect() .await .map_err(|err| { @@ -453,6 +450,8 @@ impl SchedulerClient { .connect_timeout(super::CONNECT_TIMEOUT) .timeout(super::REQUEST_TIMEOUT) .tcp_keepalive(Some(super::TCP_KEEPALIVE)) + .http2_keep_alive_interval(super::HTTP2_KEEP_ALIVE_INTERVAL) + .keep_alive_timeout(super::HTTP2_KEEP_ALIVE_TIMEOUT) .connect() .await { diff --git a/dragonfly-client/src/grpc/security.rs b/dragonfly-client/src/grpc/security.rs index b8c99435..202dbbd8 100644 --- a/dragonfly-client/src/grpc/security.rs +++ b/dragonfly-client/src/grpc/security.rs @@ -39,7 +39,6 @@ impl CertificateClient { let channel = Channel::from_static(Box::leak(addr.into_boxed_str())) .connect_timeout(super::CONNECT_TIMEOUT) .timeout(super::REQUEST_TIMEOUT) - .tcp_keepalive(Some(super::TCP_KEEPALIVE)) .connect() .await .or_err(ErrorType::ConnectError)?; diff --git a/dragonfly-client/src/proxy/mod.rs b/dragonfly-client/src/proxy/mod.rs index 8ef218d1..30aa064d 100644 --- a/dragonfly-client/src/proxy/mod.rs +++ b/dragonfly-client/src/proxy/mod.rs @@ -625,7 +625,7 @@ async fn proxy_by_dfdaemon( message.task_id.as_str(), piece.number, piece.length, - download_task_started_response.range.clone(), + download_task_started_response.range, true, ) .await diff --git a/dragonfly-client/src/resource/cache_task.rs b/dragonfly-client/src/resource/cache_task.rs index 31d5bc03..d2e7c7b6 100644 --- a/dragonfly-client/src/resource/cache_task.rs +++ b/dragonfly-client/src/resource/cache_task.rs @@ -119,7 +119,7 @@ impl CacheTask { tag: request.tag.clone(), application: request.application.clone(), piece_length: request.piece_length, - ttl: request.ttl.clone(), + ttl: request.ttl, timeout: request.timeout, }) .await @@ -129,7 +129,7 @@ impl CacheTask { })?; // Convert prost_wkt_types::Duration to std::time::Duration. - let ttl = Duration::try_from(request.ttl.clone().ok_or(Error::UnexpectedResponse)?) + let ttl = Duration::try_from(request.ttl.ok_or(Error::UnexpectedResponse)?) .or_err(ErrorType::ParseError)?; // Create the persistent cache task. diff --git a/dragonfly-client/src/resource/task.rs b/dragonfly-client/src/resource/task.rs index 55441223..0f8a239b 100644 --- a/dragonfly-client/src/resource/task.rs +++ b/dragonfly-client/src/resource/task.rs @@ -215,7 +215,7 @@ impl Task { let interested_pieces = match self.piece.calculate_interested( request.piece_length, content_length, - request.range.clone(), + request.range, ) { Ok(interested_pieces) => interested_pieces, Err(err) => { @@ -260,7 +260,7 @@ impl Task { download_task_response::Response::DownloadTaskStartedResponse( dfdaemon::v2::DownloadTaskStartedResponse { content_length, - range: request.range.clone(), + range: request.range, response_header: task.response_header.clone(), pieces, },