Skip to content

Commit

Permalink
Add legacy solvers requests compression config (#2062)
Browse files Browse the repository at this point in the history
# Description
Adds an ability to configure GZIP compression of HTTP requests in each
legacy solver.

# Changes
A new boolean `gzip_requests` config field.
k8s manifest PR cowprotocol/infrastructure#859
which is required to be deployed first

## How to test
TBD: would it be possible to test it in staging with any solver?

## Related Issues
Fixes #916
  • Loading branch information
squadgazzz authored Nov 17, 2023
1 parent e3b558b commit 148a922
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/solvers/config/example.legacy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
chain-id = "1"
solver-name = "CoW Solver"
endpoint = "https://solver.cow.fi"
gzip-requests = false
2 changes: 1 addition & 1 deletion crates/solvers/src/boundary/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Legacy {
chain_id: config.chain_id.value().as_u64(),
base,
client: reqwest::Client::new(),
gzip_requests: false,
gzip_requests: config.gzip_requests,
solve_path,
config: SolverConfig {
// Note that we unconditionally set this to "true". This is
Expand Down
1 change: 1 addition & 0 deletions crates/solvers/src/domain/solver/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Config {
pub solver_name: String,
pub chain_id: eth::ChainId,
pub endpoint: Url,
pub gzip_requests: bool,
}

pub struct Legacy(boundary::legacy::Legacy);
Expand Down
5 changes: 5 additions & 0 deletions crates/solvers/src/infra/config/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ struct Config {

/// The URL of the endpoint that responds to solve requests.
endpoint: String,

/// Enabled requests compression
#[serde(default)]
gzip_requests: bool,
}

/// Load the driver configuration from a TOML file.
Expand All @@ -44,5 +48,6 @@ pub async fn load(path: &Path) -> legacy::Config {
solver_name: config.solver_name,
chain_id: config.chain_id,
endpoint: Url::parse(&config.endpoint).unwrap(),
gzip_requests: config.gzip_requests,
}
}
1 change: 1 addition & 0 deletions crates/solvers/src/tests/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub fn config(solver_addr: &SocketAddr) -> tests::Config {
solver-name = 'legacy_solver'
endpoint = 'http://{solver_addr}/solve'
chain-id = '1'
gzip-requests = false
",
))
}

0 comments on commit 148a922

Please sign in to comment.