Skip to content

Commit c5a085f

Browse files
committed
Set db pool sizes
* set primary db pool size in middleware * set db pool sizes in test environment
1 parent 6e62024 commit c5a085f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/middleware.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn build_middleware(app: Arc<App>, endpoints: RouteBuilder) -> MiddlewareBui
8383
// In production we currently have 2 equally sized pools (primary and a read-only replica).
8484
// Because such a large portion of production traffic is for download requests (which update
8585
// download counts), we consider only the primary pool here.
86-
if let Ok(capacity) = env::var("DB_POOL_SIZE") {
86+
if let Ok(capacity) = env::var("DB_PRIMARY_POOL_SIZE") {
8787
if let Ok(capacity) = capacity.parse() {
8888
if capacity >= 10 {
8989
println!(
@@ -92,7 +92,7 @@ pub fn build_middleware(app: Arc<App>, endpoints: RouteBuilder) -> MiddlewareBui
9292
);
9393
m.around(balance_capacity::BalanceCapacity::new(capacity))
9494
} else {
95-
println!("BalanceCapacity middleware not enabled. DB_POOL_SIZE is too low.");
95+
println!("BalanceCapacity middleware not enabled. DB_PRIMARY_POOL_SIZE is too low.");
9696
}
9797
}
9898
}

src/tests/server_binary.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ impl ServerBin {
8888
// Bind a random port every time the server is started.
8989
env.insert("PORT".into(), "0".into());
9090
// Avoid creating too many database connections.
91-
env.insert("DB_POOL_SIZE".into(), "2".into());
91+
env.insert("DB_PRIMARY_POOL_SIZE".into(), "2".into());
92+
env.insert("DB_REPLICA_POOL_SIZE".into(), "1".into());
9293
env.remove("DB_MIN_SIZE");
9394
// Other configuration variables needed for the application to boot.
9495
env.insert("WEB_ALLOWED_ORIGINS".into(), "http://localhost:8888".into());

0 commit comments

Comments
 (0)