Add PG_POOL_SIZE environment variable

This commit is contained in:
Alex Gleason 2024-05-08 11:45:00 -05:00
parent b6dd49e2ef
commit 5e1cfad5cc
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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<unknown>) {