Allow max_connections to be configured in postgres

This commit is contained in:
Arjun Rao
2025-05-08 11:00:56 +10:00
parent 7ccc3ffdd7
commit f2c522ce7a
2 changed files with 6 additions and 1 deletions

View File

@@ -20,3 +20,4 @@ user = your_username
password = your_password password = your_password
database = your_database database = your_database
workspace = default # 可选,默认为default workspace = default # 可选,默认为default
max_connections = 12

View File

@@ -54,7 +54,7 @@ class PostgreSQLDB:
self.password = config.get("password", None) self.password = config.get("password", None)
self.database = config.get("database", "postgres") self.database = config.get("database", "postgres")
self.workspace = config.get("workspace", "default") self.workspace = config.get("workspace", "default")
self.max = 12 self.max = config.get("max_connections", 12)
self.increment = 1 self.increment = 1
self.pool: Pool | None = None self.pool: Pool | None = None
@@ -250,6 +250,10 @@ class ClientManager:
"POSTGRES_WORKSPACE", "POSTGRES_WORKSPACE",
config.get("postgres", "workspace", fallback="default"), config.get("postgres", "workspace", fallback="default"),
), ),
"max_connections": os.environ.get(
"POSTGRES_MAX_CONNECTIONS",
config.get("postgres", "max_connections", fallback=12),
),
} }
@classmethod @classmethod