feat(tvix/nar-bridge): support zstd content-encoding

We previously didn't handle compression in nar-bridge, and left it up to
a fronting reverse proxy.

However, at least nginx with http2 enabled pins each connection to a
single core, causing compression to be limited by the throughput of a
single CPU.

Change-Id: Ia11c2ff5c012192b25eb8ad05dae5542a2d2f777
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12834
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Reviewed-by: Jörg Thalheim <joerg@thalheim.io>
This commit is contained in:
Florian Klink 2024-11-24 09:35:35 +02:00 committed by clbot
parent a7080a1468
commit f6aee3534b
4 changed files with 52 additions and 16 deletions

View file

@ -64,6 +64,8 @@ pub fn gen_router(priority: u64) -> Router<AppState> {
.route("/:narinfo_str", put(narinfo::put))
.route("/nix-cache-info", get(move || nix_cache_info(priority)));
let router = router.layer(tower_http::compression::CompressionLayer::new());
#[cfg(feature = "otlp")]
return router.layer(metrics_layer);
#[cfg(not(feature = "otlp"))]