From 5e1cfad5cc0e51f30e4ade5c83ab7a96a9b465b6 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 8 May 2024 11:45:00 -0500 Subject: [PATCH] Add PG_POOL_SIZE environment variable --- src/config.ts | 7 +++++++ src/db/adapters/DittoPostgres.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 2e8004f..4266033 100644 --- a/src/config.ts +++ b/src/config.ts @@ -208,6 +208,13 @@ class Conf { } }, }; + /** Postgres settings. */ + static pg = { + /** Number of connections to use in the pool. */ + get poolSize(): number { + return Number(Deno.env.get('PG_POOL_SIZE') ?? 10); + }, + }; } const optionalBooleanSchema = z diff --git a/src/db/adapters/DittoPostgres.ts b/src/db/adapters/DittoPostgres.ts index 2d9d9f1..541c1d7 100644 --- a/src/db/adapters/DittoPostgres.ts +++ b/src/db/adapters/DittoPostgres.ts @@ -1,6 +1,7 @@ import { Kysely, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler } from 'kysely'; import { PostgreSQLDriver } from 'kysely_deno_postgres'; +import { Conf } from '@/config.ts'; import { DittoTables } from '@/db/DittoTables.ts'; export class DittoPostgres { @@ -18,7 +19,7 @@ export class DittoPostgres { createDriver() { return new PostgreSQLDriver( { connectionString: Deno.env.get('DATABASE_URL') }, - navigator.hardwareConcurrency, + Conf.pg.poolSize, ); }, createIntrospector(db: Kysely) {