Skip to content

Commit

Permalink
feat(rpc): add max connections config
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Jul 26, 2023
1 parent a29ff9f commit 702b9fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cli/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ pub struct RpcArgs {
default_value = "20"
)]
timeout_seconds: String,

/// Maximum number of concurrent connections
#[arg(
long = "rpc.max_connections",
name = "rpc.max_connections",
env = "RPC_MAX_CONNECTIONS",
default_value = "100"
)]
max_connections: u32,
}

impl RpcArgs {
Expand Down Expand Up @@ -99,6 +108,7 @@ impl RpcArgs {
sim_settings,
estimation_settings,
rpc_timeout: Duration::from_secs(self.timeout_seconds.parse()?),
max_connections: self.max_connections,
mempool_configs,
})
}
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct Args {
pub sim_settings: simulation::Settings,
pub estimation_settings: estimation::Settings,
pub rpc_timeout: Duration,
pub max_connections: u32,
pub mempool_configs: HashMap<H256, MempoolConfig>,
}

Expand Down Expand Up @@ -146,6 +147,7 @@ impl Task for RpcTask {
let server = ServerBuilder::default()
.set_logger(RpcMetricsLogger)
.set_middleware(service_builder)
.max_connections(self.args.max_connections)
.http_only()
.build(addr)
.await?;
Expand Down

0 comments on commit 702b9fd

Please sign in to comment.