perf(gateway): raise default server pool floor

This commit is contained in:
elky
2026-08-12 16:56:18 +08:00
parent 3a759fae89
commit 29fa4aed19
4 changed files with 37 additions and 4 deletions
+29
View File
@@ -195,6 +195,35 @@ mod tests {
assert_eq!(background.pool.min_connections, 1);
}
#[test]
fn runtime_pool_split_gives_default_small_server_more_foreground_capacity() {
let config = GatewayDataConfig::from_database_config(
SqlDatabaseConfig::new(
DatabaseDriver::Postgres,
"postgres://localhost/aether",
SqlPoolConfig {
min_connections: 4,
max_connections: 32,
..SqlPoolConfig::default()
},
)
.expect("database config should be valid"),
);
let (foreground, background) = config.split_runtime_pools_with_background_max(None);
let foreground = foreground.database().expect("foreground database");
let background = background
.expect("background database config")
.database()
.expect("background database")
.clone();
assert_eq!(foreground.pool.max_connections, 26);
assert_eq!(background.pool.max_connections, 6);
assert_eq!(foreground.pool.min_connections, 4);
assert_eq!(background.pool.min_connections, 1);
}
#[test]
fn runtime_pool_split_can_be_disabled_or_degrade_for_single_connection() {
let mut database = SqlDatabaseConfig::sqlite_default();