diff --git a/Cargo.toml b/Cargo.toml index cac91e7..19105fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ serde = "1.0" serde_derive = "1.0" thiserror = "1" tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] } -tonic = { version = "0.10", features = ["tls"] } +tonic = { version = "0.10", features = ["tls", "gzip"] } [dev-dependencies] clap = "2" diff --git a/config/tikv.toml b/config/tikv.toml index 6eef5b2..d27ebb5 100644 --- a/config/tikv.toml +++ b/config/tikv.toml @@ -17,3 +17,6 @@ max-open-files = 10000 [storage] reserve-space = "0MiB" + +[server] +grpc-compression-type = "gzip" diff --git a/src/store/client.rs b/src/store/client.rs index 88880c7..1c87328 100644 --- a/src/store/client.rs +++ b/src/store/client.rs @@ -6,6 +6,7 @@ use std::time::Duration; use async_trait::async_trait; use derive_new::new; +use tonic::codec::CompressionEncoding; use tonic::transport::Channel; use super::Request; @@ -37,6 +38,7 @@ impl KvConnect for TikvConnect { .connect(address, move |channel| { TikvClient::new(channel) .max_decoding_message_size(self.grpc_max_decoding_message_size) + .accept_compressed(CompressionEncoding::Gzip) }) .await .map(|c| KvRpcClient::new(c, self.timeout))