Skip to content

Commit

Permalink
feat: add zstd compression for grpc (#658)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Aug 7, 2024
1 parent 6c7e70d commit 8796c42
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 18 deletions.
36 changes: 27 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ members = [
]

[workspace.package]
version = "0.1.95"
version = "0.1.96"
authors = ["The Dragonfly Developers"]
homepage = "https://d7y.io/"
repository = "https://github.com/dragonflyoss/client.git"
Expand All @@ -22,13 +22,13 @@ readme = "README.md"
edition = "2021"

[workspace.dependencies]
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" }
dragonfly-client = { path = "dragonfly-client", version = "0.1.96" }
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.96" }
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.96" }
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.96" }
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.96" }
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.96" }
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.96" }
thiserror = "1.0"
dragonfly-api = "2.0.143"
reqwest = { version = "0.12.4", features = ["stream", "native-tls", "default-tls", "rustls-tls"] }
Expand Down Expand Up @@ -59,7 +59,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9"
serde_json = "1.0"
http = "1"
tonic = { version = "0.12.1", features = ["gzip"] }
tonic = { version = "0.12.1", features = ["zstd"] }
tokio = { version = "1.39.2", features = ["full"] }
tokio-util = { version = "0.7.11", features = ["full"] }
tokio-stream = "0.1.15"
Expand Down
5 changes: 5 additions & 0 deletions dragonfly-client/src/grpc/dfdaemon_download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use tokio::fs;
use tokio::net::{UnixListener, UnixStream};
use tokio::sync::mpsc;
use tokio_stream::wrappers::{ReceiverStream, UnixListenerStream};
use tonic::codec::CompressionEncoding;
use tonic::{
transport::{Channel, Endpoint, Server, Uri},
Code, Request, Response, Status,
Expand Down Expand Up @@ -90,6 +91,8 @@ impl DfdaemonDownloadServer {
task,
cache_task,
})
.send_compressed(CompressionEncoding::Zstd)
.accept_compressed(CompressionEncoding::Zstd)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX);

Expand Down Expand Up @@ -1001,6 +1004,8 @@ impl DfdaemonDownloadClient {
})
.or_err(ErrorType::ConnectError)?;
let client = DfdaemonDownloadGRPCClient::new(channel)
.send_compressed(CompressionEncoding::Zstd)
.accept_compressed(CompressionEncoding::Zstd)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX);
Ok(Self { client })
Expand Down
5 changes: 5 additions & 0 deletions dragonfly-client/src/grpc/dfdaemon_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use std::time::{Duration, Instant};
use tokio::io::AsyncReadExt;
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
use tonic::codec::CompressionEncoding;
use tonic::{
transport::{Channel, Server},
Code, Request, Response, Status,
Expand Down Expand Up @@ -85,6 +86,8 @@ impl DfdaemonUploadServer {
task,
cache_task,
})
.send_compressed(CompressionEncoding::Zstd)
.accept_compressed(CompressionEncoding::Zstd)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX);

Expand Down Expand Up @@ -1006,6 +1009,8 @@ impl DfdaemonUploadClient {
})
.or_err(ErrorType::ConnectError)?;
let client = DfdaemonUploadGRPCClient::new(channel)
.send_compressed(CompressionEncoding::Zstd)
.accept_compressed(CompressionEncoding::Zstd)
.max_decoding_message_size(usize::MAX)
.max_encoding_message_size(usize::MAX);
Ok(Self { client })
Expand Down

0 comments on commit 8796c42

Please sign in to comment.