Skip to content

Commit 5dd2ca5

Browse files
authored
config max subscriptions per connection (#198)
* config max subscriptions per connection * fix * fix
1 parent a97673b commit 5dd2ca5

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

benches/bench/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ fn config() -> Config {
222222
listen_address: SUBWAY_SERVER_ADDR.to_string(),
223223
port: SUBWAY_SERVER_PORT,
224224
max_connections: 1024 * 1024,
225+
max_subscriptions_per_connection: 1024,
225226
max_batch_size: None,
226227
request_timeout_seconds: 120,
227228
http_methods: Vec::new(),

src/extensions/server/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ pub struct ServerConfig {
5959
pub port: u16,
6060
pub listen_address: String,
6161
pub max_connections: u32,
62+
#[serde(default = "default_max_subscriptions_per_connection")]
63+
pub max_subscriptions_per_connection: u32,
6264
pub max_batch_size: Option<u32>,
6365
#[serde(default)]
6466
pub http_methods: Vec<HttpMethodsConfig>,
@@ -72,6 +74,10 @@ fn default_request_timeout_seconds() -> u64 {
7274
120
7375
}
7476

77+
fn default_max_subscriptions_per_connection() -> u32 {
78+
1024
79+
}
80+
7581
#[async_trait]
7682
impl Extension for SubwayServerBuilder {
7783
type Config = ServerConfig;
@@ -172,6 +178,7 @@ impl SubwayServerBuilder {
172178
.set_http_middleware(http_middleware)
173179
.set_batch_request_config(batch_request_config)
174180
.max_connections(config.max_connections)
181+
.max_subscriptions_per_connection(config.max_subscriptions_per_connection)
175182
.set_id_provider(RandomStringIdProvider::new(16))
176183
.to_service_builder(),
177184
rate_limit_builder,

src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ mod tests {
259259
listen_address: "127.0.0.1".to_string(),
260260
port,
261261
max_connections: 1024,
262+
max_subscriptions_per_connection: 1024,
262263
max_batch_size,
263264
request_timeout_seconds: request_timeout_seconds.unwrap_or(10),
264265
http_methods: Vec::new(),

src/tests/merge_subscription.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async fn merge_subscription_works() {
5454
listen_address: "0.0.0.0".to_string(),
5555
port: 0,
5656
max_connections: 10,
57+
max_subscriptions_per_connection: 1024,
5758
max_batch_size: None,
5859
request_timeout_seconds: 120,
5960
http_methods: Vec::new(),

src/tests/upstream.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async fn upstream_error_propagate() {
3636
listen_address: "0.0.0.0".to_string(),
3737
port: 0,
3838
max_connections: 10,
39+
max_subscriptions_per_connection: 1024,
3940
max_batch_size: None,
4041
request_timeout_seconds: 120,
4142
http_methods: Vec::new(),

0 commit comments

Comments
 (0)