Skip to content

Commit

Permalink
make connection pools configurable at runtime, increase defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
leondutoit committed Oct 11, 2024
1 parent 7c2fcb8 commit a3efc8e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tsdfileapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2988,10 +2988,13 @@ def __init__(self, config: dict) -> None:
logger.warning(f"could not connect to request log db: {e}")

def initdb(self, name: str, opts: tornado.options.OptionParser) -> None:
engine_type = options.config["backends"]["dbs"][name]["db"]["engine"]
db_config = options.config["backends"]["dbs"][name]["db"]
engine_type = db_config["engine"]
if engine_type == "postgres":
pool = postgres_init(
options.config["backends"]["dbs"][name]["db"]["dbconfig"]
db_config["dbconfig"],
db_config.get("pool_min", 3),
db_config.get("pool_max", 5),
)
options.pgpools[name] = pool
db = PostgresBackend(pool)
Expand All @@ -3002,9 +3005,14 @@ def initdb(self, name: str, opts: tornado.options.OptionParser) -> None:
def initdb_request_log(self) -> None:
if not options.request_log:
return
engine_type = options.request_log.get("db").get("engine")
db_config = options.request_log.get("db")
engine_type = db_config.get("engine")
if engine_type == "postgres":
pool = postgres_init(options.request_log.get("db").get("dbconfig"))
pool = postgres_init(
db_config.get("dbconfig"),
db_config.get("pool_min", 3),
db_config.get("pool_max", 5),
)
try:
define("pgpool_request_log", pool)
except tornado.options.Error:
Expand Down

0 comments on commit a3efc8e

Please sign in to comment.