broker: make Postgres pool size configurable, bump default 5 → 8
Under concurrent door executions the broker was queueing on its 5-connection pool, adding latency to tool calls that fanned out from the same run. Bump the default to 8 (one connection per concurrent door before queueing) and expose CLAWMATES_BROKER_POOL_SIZE so the fleet can tune it up as the load grows without a rebuild.
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
//! it by construction.
|
||||
//!
|
||||
//! Configuration (environment):
|
||||
//! - `CLAWMATES_DATABASE__URL` Postgres connection string (required)
|
||||
//! - `CLAWMATES_BROKER_SOCKET` unix socket path (default /tmp/clawmates-broker.sock)
|
||||
//! - `CLAWMATES_BROKER_KEY_FILE` master key file; generated on first boot
|
||||
//! - `CLAWMATES_DATABASE__URL` Postgres connection string (required)
|
||||
//! - `CLAWMATES_BROKER_SOCKET` unix socket path (default /tmp/clawmates-broker.sock)
|
||||
//! - `CLAWMATES_BROKER_KEY_FILE` master key file; generated on first boot
|
||||
//! - `CLAWMATES_BROKER_POOL_SIZE` max Postgres connections (default 8)
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::process::ExitCode;
|
||||
@@ -45,7 +46,13 @@ async fn run() -> Result<(), String> {
|
||||
}
|
||||
let key = FileKey::load(&key_path).map_err(|e| format!("key load failed: {e}"))?;
|
||||
|
||||
let pool = cm_db::connect(&database_url, 5)
|
||||
// Pool size defaults to 8: one broker connection per concurrent door
|
||||
// execution before we start queueing. Tune via env when the fleet grows.
|
||||
let pool_size: u32 = std::env::var("CLAWMATES_BROKER_POOL_SIZE")
|
||||
.ok()
|
||||
.and_then(|v| v.parse().ok())
|
||||
.unwrap_or(8);
|
||||
let pool = cm_db::connect(&database_url, pool_size)
|
||||
.await
|
||||
.map_err(|e| format!("database connection failed: {e}"))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user