Skip to content

Commit

Permalink
Rename cas CompressionAlgorithm to HttpCompressionAlgorithm (#1052)
Browse files Browse the repository at this point in the history
This disambiguates it from `stores::CompressionAlgorithm`.
  • Loading branch information
aaronmondal authored Jun 25, 2024
1 parent 684dbc1 commit 9ba4323
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions nativelink-config/src/cas_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub type InstanceName = String;

#[allow(non_camel_case_types)]
#[derive(Deserialize, Debug, Default, Clone, Copy)]
pub enum CompressionAlgorithm {
pub enum HttpCompressionAlgorithm {
/// No compression.
#[default]
none,
Expand All @@ -54,15 +54,15 @@ pub enum CompressionAlgorithm {
/// and cloud-clients to use another.
#[derive(Deserialize, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct CompressionConfig {
pub struct HttpCompressionConfig {
/// The compression algorithm that the server will use when sending
/// responses to clients. Enabling this will likely save a lot of
/// data transfer, but will consume a lot of CPU and add a lot of
/// latency.
/// see: <https://github.com/tracemachina/nativelink/issues/109>
///
/// Default: CompressionAlgorithm::None
pub send_compression_algorithm: Option<CompressionAlgorithm>,
/// Default: `HttpCompressionAlgorithm::none`
pub send_compression_algorithm: Option<HttpCompressionAlgorithm>,

/// The compression algorithm that the server will accept from clients.
/// The server will broadcast the supported compression algorithms to
Expand All @@ -72,7 +72,7 @@ pub struct CompressionConfig {
/// see: <https://github.com/tracemachina/nativelink/issues/109>
///
/// Defaults: {no supported compression}
pub accepted_compression_algorithms: Vec<CompressionAlgorithm>,
pub accepted_compression_algorithms: Vec<HttpCompressionAlgorithm>,
}

#[derive(Deserialize, Debug)]
Expand Down Expand Up @@ -371,7 +371,7 @@ pub struct HttpListener {

/// Data transport compression configuration to use for this service.
#[serde(default)]
pub compression: CompressionConfig,
pub compression: HttpCompressionConfig,

/// Advanced Http server configuration.
#[serde(default)]
Expand Down
22 changes: 11 additions & 11 deletions src/bin/nativelink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use hyper::server::conn::Http;
use hyper::{Response, StatusCode};
use mimalloc::MiMalloc;
use nativelink_config::cas_server::{
CasConfig, CompressionAlgorithm, GlobalConfig, ListenerConfig, ServerConfig, WorkerConfig,
CasConfig, GlobalConfig, HttpCompressionAlgorithm, ListenerConfig, ServerConfig, WorkerConfig,
};
use nativelink_config::stores::ConfigDigestHashFunction;
use nativelink_error::{make_err, Code, Error, ResultExt};
Expand Down Expand Up @@ -152,10 +152,10 @@ async fn inner_main(
}
}

fn into_encoding(from: &CompressionAlgorithm) -> Option<CompressionEncoding> {
fn into_encoding(from: &HttpCompressionAlgorithm) -> Option<CompressionEncoding> {
match from {
CompressionAlgorithm::gzip => Some(CompressionEncoding::Gzip),
CompressionAlgorithm::none => None,
HttpCompressionAlgorithm::gzip => Some(CompressionEncoding::Gzip),
HttpCompressionAlgorithm::none => None,
}
}

Expand Down Expand Up @@ -237,7 +237,7 @@ async fn inner_main(
let mut service = v.into_service();
let send_algo = &http_config.compression.send_compression_algorithm;
if let Some(encoding) =
into_encoding(&send_algo.unwrap_or(CompressionAlgorithm::none))
into_encoding(&send_algo.unwrap_or(HttpCompressionAlgorithm::none))
{
service = service.send_compressed(encoding);
}
Expand All @@ -263,7 +263,7 @@ async fn inner_main(
let mut service = v.into_service();
let send_algo = &http_config.compression.send_compression_algorithm;
if let Some(encoding) =
into_encoding(&send_algo.unwrap_or(CompressionAlgorithm::none))
into_encoding(&send_algo.unwrap_or(HttpCompressionAlgorithm::none))
{
service = service.send_compressed(encoding);
}
Expand All @@ -289,7 +289,7 @@ async fn inner_main(
let mut service = v.into_service();
let send_algo = &http_config.compression.send_compression_algorithm;
if let Some(encoding) =
into_encoding(&send_algo.unwrap_or(CompressionAlgorithm::none))
into_encoding(&send_algo.unwrap_or(HttpCompressionAlgorithm::none))
{
service = service.send_compressed(encoding);
}
Expand All @@ -315,7 +315,7 @@ async fn inner_main(
let mut service = v.into_service();
let send_algo = &http_config.compression.send_compression_algorithm;
if let Some(encoding) =
into_encoding(&send_algo.unwrap_or(CompressionAlgorithm::none))
into_encoding(&send_algo.unwrap_or(HttpCompressionAlgorithm::none))
{
service = service.send_compressed(encoding);
}
Expand Down Expand Up @@ -355,7 +355,7 @@ async fn inner_main(
let mut service = v.into_service();
let send_algo = &http_config.compression.send_compression_algorithm;
if let Some(encoding) =
into_encoding(&send_algo.unwrap_or(CompressionAlgorithm::none))
into_encoding(&send_algo.unwrap_or(HttpCompressionAlgorithm::none))
{
service = service.send_compressed(encoding);
}
Expand All @@ -379,7 +379,7 @@ async fn inner_main(
let mut service = v.into_service();
let send_algo = &http_config.compression.send_compression_algorithm;
if let Some(encoding) =
into_encoding(&send_algo.unwrap_or(CompressionAlgorithm::none))
into_encoding(&send_algo.unwrap_or(HttpCompressionAlgorithm::none))
{
service = service.send_compressed(encoding);
}
Expand All @@ -405,7 +405,7 @@ async fn inner_main(
let mut service = v.into_service();
let send_algo = &http_config.compression.send_compression_algorithm;
if let Some(encoding) =
into_encoding(&send_algo.unwrap_or(CompressionAlgorithm::none))
into_encoding(&send_algo.unwrap_or(HttpCompressionAlgorithm::none))
{
service = service.send_compressed(encoding);
}
Expand Down

0 comments on commit 9ba4323

Please sign in to comment.