Skip to content

Commit 001b8bb

Browse files
committed
FIX: add configurable max connection limit per tenant if needed
1 parent 9d10fea commit 001b8bb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ POSTGRES_PORT=5432
33
POSTGRES_USER=postgres
44
POSTGRES_PASSWORD=postgres
55
POSTGRES_DB=authentication-service
6+
POSTGRES_TENANT_MAX_CONNECTION_LIMIT=10
67
REDIS_HOST=localhost
78
REDIS_PORT=6379
89
REDIS_CACHE_TTL=3600

src/util/database.connection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export async function getConnectionForTenant(
4141
synchronize: false,
4242
logging: ['error'],
4343
namingStrategy: new SnakeNamingStrategy(),
44-
extra: { max: process.env.POSTGRES_TENANT_MAX_CONNECTION_LIMIT },
44+
...(process.env.POSTGRES_TENANT_MAX_CONNECTION_LIMIT
45+
? { extra: { max: process.env.POSTGRES_TENANT_MAX_CONNECTION_LIMIT } }
46+
: {}),
4547
}).initialize();
4648

4749
await switchToTenant(tenantId, newConnection);

0 commit comments

Comments
 (0)