perf(db): configure database connection pools

Add configurable PostgreSQL and database/sql pool limits, validate invalid environment values, clamp idle connections, and cover the parsing/application logic with unit tests.
This commit is contained in:
姚章浩
2026-07-15 13:16:23 +08:00
parent 77e4f93e3e
commit 4022040e98
4 changed files with 186 additions and 2 deletions
+9
View File
@@ -210,6 +210,15 @@ DB_PASSWORD=postgres123!@#
# 数据库名称
DB_NAME=WeKnora
# PostgreSQL 全局最大连接数(Compose 内置 PostgreSQL 服务)
POSTGRES_MAX_CONNECTIONS=300
# WeKnora database/sql 连接池
DB_MAX_OPEN_CONNS=120
DB_MAX_IDLE_CONNS=20
DB_CONN_MAX_IDLE_TIME=5m
DB_CONN_MAX_LIFETIME=10m
# 如果使用 redis 作为流处理后端,需要配置以下参数
# Redis用户名,Redis 6.0+ ACL 功能支持(可选)
# REDIS_USERNAME=