Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ default-members = ["crates/rproxy"]
members = [
"crates/rproxy",
]

[profile.flamegraph]
inherits = "release"
debug = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

11 changes: 2 additions & 9 deletions crates/rproxy/src/metrics/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
use std::{net::TcpListener, sync::Arc, time::Duration};

use actix_web::{
Copy link
Contributor

@0x416e746f6e 0x416e746f6e Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion/question:

this project uses the nightly formatter with vertical alignment.

your PR is apparently on a stable.

I don't hold strong feelings about either, but it would be good to stick to a convention early on.

w.d.y.t.?

App,
HttpRequest,
HttpResponse,
HttpServer,
middleware::{NormalizePath, TrailingSlash},
web,
};
use actix_web::{App, HttpRequest, HttpResponse, HttpServer, middleware::NormalizePath, web};
use awc::http::Method;
use prometheus_client::{
metrics::{counter::Counter, family::Family, gauge::Gauge},
Expand Down Expand Up @@ -287,7 +280,7 @@ impl Metrics {
let server = match HttpServer::new(move || {
App::new()
.app_data(web::Data::new(self.clone()))
.wrap(NormalizePath::new(TrailingSlash::Trim))
.wrap(NormalizePath::trim())
.default_service(web::route().to(Self::receive))
})
.workers(1)
Expand Down
16 changes: 12 additions & 4 deletions crates/rproxy/src/proxy_http/proxy_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use actix_web::{
HttpServer,
body::BodySize,
http::{StatusCode, header},
middleware::{NormalizePath, TrailingSlash},
middleware::NormalizePath,
web,
};
use awc::{
Expand Down Expand Up @@ -179,7 +179,7 @@ where

App::new()
.app_data(this)
.wrap(NormalizePath::new(TrailingSlash::Trim))
.wrap(NormalizePath::trim())
.default_service(web::route().to(Self::receive))
})
.on_connect(Self::on_connect(metrics, client_connections_count))
Expand Down Expand Up @@ -250,10 +250,16 @@ where
socket.set_tcp_keepalive(
&socket2::TcpKeepalive::new()
.with_time(
config.idle_connection_timeout().div_f64(f64::from(TCP_KEEPALIVE_ATTEMPTS)),
config
.idle_connection_timeout()
.checked_div(TCP_KEEPALIVE_ATTEMPTS)
.expect("duration is not zero"),
)
.with_interval(
config.idle_connection_timeout().div_f64(f64::from(TCP_KEEPALIVE_ATTEMPTS)),
config
.idle_connection_timeout()
.checked_div(TCP_KEEPALIVE_ATTEMPTS)
.expect("duration is not zero"),
)
.with_retries(TCP_KEEPALIVE_ATTEMPTS - 1),
)?;
Expand Down Expand Up @@ -457,11 +463,13 @@ where
) {
if cli_req.decompressed_size < cli_req.size {
(cli_req.decompressed_body, cli_req.decompressed_size) =
// TODO: remove this clone
decompress(cli_req.body.clone(), cli_req.size, cli_req.info.content_encoding());
}

if mrr_res.decompressed_size < mrr_res.size {
(mrr_res.decompressed_body, mrr_res.decompressed_size) =
// TODO: remove this clone
decompress(mrr_res.body.clone(), mrr_res.size, mrr_res.info.content_encoding());
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rproxy/src/proxy_http/proxy_http_inner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl ProxyHttpInner<ConfigRpc> for ProxyHttpInnerRpc {
return false;
}

return mirror_errored_requests || jrpc_res.error.is_none()
return mirror_errored_requests || jrpc_res.error.is_none();
}

match jrpc_req {
Expand Down
11 changes: 2 additions & 9 deletions crates/rproxy/src/proxy_ws/proxy_ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ use std::{
};

use actix::{Actor, AsyncContext, WrapFuture};
use actix_web::{
App,
HttpRequest,
HttpResponse,
HttpServer,
middleware::{NormalizePath, TrailingSlash},
web,
};
use actix_web::{App, HttpRequest, HttpResponse, HttpServer, middleware::NormalizePath, web};
use actix_ws::{MessageStream, Session};
use bytes::{Buf, BufMut, Bytes, BytesMut};
use futures::{
Expand Down Expand Up @@ -158,7 +151,7 @@ where

App::new()
.app_data(this)
.wrap(NormalizePath::new(TrailingSlash::Trim))
.wrap(NormalizePath::trim())
.default_service(web::route().to(Self::receive))
})
.on_connect(Self::on_connect(metrics, client_connections_count))
Expand Down
2 changes: 1 addition & 1 deletion crates/rproxy/src/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Server {
let resetter = Server::wait_for_reset_signal(canceller.clone());

// spawn metrics service
let metrics = Arc::new(Metrics::new(config.metrics.clone()));
let metrics = Arc::new(Metrics::new(config.metrics));
{
let canceller = canceller.clone();
let metrics = metrics.clone();
Expand Down