File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ Environment variables
2424| ` TENANT_HEADER ` | ` <empty> ` | The name of the HTTP header which contains the tenant name for multi-tenant setups. |
2525| ` TENANT_PATH_PREFIX ` | ` @service_prefix@/@tenant@ ` | URL path prefix for all QWC services for multi-tenant setups. |
2626| ` TENANT_ACCESS_COOKIE_PATH ` | ` <tenant_path_prefix> ` | Path for which the access cookie is valid for multi-tenant setups. |
27+ | ` POOL_SIZE ` | ` 5 ` | Maximum number of possible data base connections. |
28+ | ` MAX_OVERFLOW ` | ` 10 ` | Additional connections beyond pool_size during peak load. |
29+ | ` POOL_TIMEOUT ` | ` 30 ` | Time (in seconds) to wait for a connection to become available. |
30+ | ` POOL_RECYCLE ` | ` -1 ` | Time (in seconds) after idle connections will be resetted. |
2731
2832Development
2933===========
Original file line number Diff line number Diff line change 11import os
22
33from sqlalchemy import create_engine
4-
4+ from sqlalchemy . pool import QueuePool
55
66class DatabaseEngine ():
77 """Helper for database connections using SQLAlchemy engines"""
@@ -15,12 +15,24 @@ def db_engine(self, conn_str):
1515
1616 :param str conn_str: DB connection string for SQLAlchemy engine
1717
18- see http ://docs.sqlalchemy.org/en/latest/core/engines.html#postgresql
18+ see https ://docs.sqlalchemy.org/en/latest/core/engines.html#postgresql
1919 """
20+
21+ db_pool_size = os .environ .get ('POOL_SIZE' , 5 )
22+ db_max_overflow = os .environ .get ('MAX_OVERFLOW' , 10 )
23+ db_pool_timeout = os .environ .get ('POOL_TIMEOUT' , 30 )
24+ db_pool_recycle = os .environ .get ('POOL_RECYCLE' , - 1 )
25+
2026 engine = self .engines .get (conn_str )
2127 if not engine :
2228 engine = create_engine (
23- conn_str , pool_pre_ping = True , echo = False )
29+ conn_str ,
30+ poolclass = QueuePool ,
31+ pool_size = db_pool_size ,
32+ max_overflow = db_max_overflow ,
33+ pool_timeout = db_pool_timeout ,
34+ pool_recycle = db_pool_recycle ,
35+ pool_pre_ping = True , echo = False )
2436 self .engines [conn_str ] = engine
2537 return engine
2638
You can’t perform that action at this time.
0 commit comments