diff --git a/Cargo.lock b/Cargo.lock index 036f237d..76aa9d8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "ahash" version = "0.8.11" @@ -154,7 +160,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.2", "object", "rustc-demangle", ] @@ -265,6 +271,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-queue" version = "0.3.11" @@ -413,6 +428,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +dependencies = [ + "crc32fast", + "miniz_oxide 0.8.0", +] + [[package]] name = "flume" version = "0.11.0" @@ -879,6 +904,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "0.8.11" @@ -1949,6 +1983,7 @@ dependencies = [ "axum", "base64", "bytes", + "flate2", "h2", "http", "http-body", diff --git a/stationapi/Cargo.toml b/stationapi/Cargo.toml index 94ad605d..4b65ea12 100644 --- a/stationapi/Cargo.toml +++ b/stationapi/Cargo.toml @@ -14,7 +14,7 @@ sqlx = { version = "0.7", features = [ "mysql", ] } tokio = { version = "1.28.0", features = ["full"] } -tonic = "0.10.1" +tonic = { version = "0.10.1", features = ["gzip"] } tonic-web = "0.10.1" tracing = "0.1.37" tracing-subscriber = "0.3.17" diff --git a/stationapi/src/main.rs b/stationapi/src/main.rs index 3db81e6e..c141b055 100644 --- a/stationapi/src/main.rs +++ b/stationapi/src/main.rs @@ -13,6 +13,7 @@ use std::{ env::{self, VarError}, net::{AddrParseError, SocketAddr}, }; +use tonic::codec::CompressionEncoding; use tonic::transport::Server; use tonic_health::server::HealthReporter; use tracing::{info, warn}; @@ -72,7 +73,9 @@ async fn run() -> std::result::Result<(), anyhow::Error> { let my_api = MyApi { query_use_case }; - let svc = StationApiServer::new(my_api); + let svc = StationApiServer::new(my_api) + .send_compressed(CompressionEncoding::Gzip) + .accept_compressed(CompressionEncoding::Gzip); info!("StationAPI Server listening on {}", addr);