Merge branch 'pg-pool-size' into 'main'

Add PG_POOL_SIZE environment variable

See merge request soapbox-pub/ditto!233
This commit is contained in:
Alex Gleason 2024-05-08 16:49:42 +00:00
commit dbe22b9710
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>) {