Skip to content

Commit 0131bd9

Browse files
feat: Support compressing HTTP contents (#74)
* Support compressing HTTP contents * Apply suggestions from code review Co-authored-by: Malte Sander <[email protected]> --------- Co-authored-by: Malte Sander <[email protected]>
1 parent d689a88 commit 0131bd9

File tree

4 files changed

+89
-2
lines changed

4 files changed

+89
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
88

99
- Support configuring compression for OTEL ([#70]).
1010
- Improve tracing details by adding a `tower_http::trace::TraceLayer` that creates spans for every HTTP request ([#71]).
11+
- Support compressing HTTP contents, previously the content was always uncompressed.
12+
This consumes more CPU, but also reduces the data amount sent to Trino clients.
13+
E.g. `trino-cli` by default asks for `gzip` compressed content ([#74]).
1114

1215
### Changed
1316

@@ -17,6 +20,7 @@ All notable changes to this project will be documented in this file.
1720
[#70]: https://github.com/stackabletech/trino-lb/pull/70
1821
[#71]: https://github.com/stackabletech/trino-lb/pull/71
1922
[#73]: https://github.com/stackabletech/trino-lb/pull/73
23+
[#74]: https://github.com/stackabletech/trino-lb/pull/74
2024

2125
## [0.4.1] - 2025-03-03
2226

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ sqlx = { version = "0.8.2", features = [
8282
strum = { version = "0.27", features = ["derive"] }
8383
tokio = "1.39"
8484
tower = "0.5"
85-
tower-http = { version = "0.6", features = ["tracing"] }
85+
tower-http = { version = "0.6", features = ["compression-full", "tracing"] }
8686
tracing = "0.1"
8787
tracing-opentelemetry = "0.25"
8888
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

trino-lb/src/http_server/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use axum_server::{tls_rustls::RustlsConfig, Handle};
1515
use futures::FutureExt;
1616
use snafu::{OptionExt, ResultExt, Snafu};
1717
use tokio::time::sleep;
18-
use tower_http::trace::TraceLayer;
18+
use tower_http::{compression::CompressionLayer, trace::TraceLayer};
1919
use tracing::info;
2020
use trino_lb_persistence::PersistenceImplementation;
2121

@@ -124,6 +124,7 @@ pub async fn start_http_server(
124124
.route("/ui/index.html", get(ui::index::get_ui_index))
125125
.route("/ui/query.html", get(ui::query::get_ui_query))
126126
.layer(TraceLayer::new_for_http())
127+
.layer(CompressionLayer::new())
127128
.with_state(app_state);
128129

129130
if tls_config.enabled {

0 commit comments

Comments
 (0)