Skip to content

Commit

Permalink
feat(katana): configurable max RPC connections (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI authored Oct 27, 2023
1 parent 45fb6af commit b7a8465
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/dojo-test-utils/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl TestSequencer {
ServerConfig {
port: 0,
host: "0.0.0.0".into(),
max_connections: 100,
apis: vec![ApiKind::Starknet, ApiKind::Katana],
},
)
Expand Down
1 change: 1 addition & 0 deletions crates/katana/rpc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::api::ApiKind;
pub struct ServerConfig {
pub port: u16,
pub host: String,
pub max_connections: u32,
pub apis: Vec<ApiKind>,
}

Expand Down
1 change: 1 addition & 0 deletions crates/katana/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub async fn spawn(sequencer: Arc<KatanaSequencer>, config: ServerConfig) -> Res
.set_logger(RpcLogger)
.set_host_filtering(AllowHosts::Any)
.set_middleware(middleware)
.max_connections(config.max_connections)
.build(config.addr())
.await?;

Expand Down
6 changes: 6 additions & 0 deletions crates/katana/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ pub struct ServerOptions {
#[arg(long)]
#[arg(help = "The IP address the server will listen on.")]
pub host: Option<String>,

#[arg(long)]
#[arg(default_value = "100")]
#[arg(help = "Maximum number of concurrent connections allowed.")]
pub max_connections: u32,
}

#[derive(Debug, Args, Clone)]
Expand Down Expand Up @@ -184,6 +189,7 @@ impl KatanaArgs {
apis,
port: self.server.port,
host: self.server.host.clone().unwrap_or("0.0.0.0".into()),
max_connections: self.server.max_connections,
}
}

Expand Down

0 comments on commit b7a8465

Please sign in to comment.