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:
commit
dbe22b9710
|
@ -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
|
const optionalBooleanSchema = z
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { Kysely, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler } from 'kysely';
|
import { Kysely, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler } from 'kysely';
|
||||||
import { PostgreSQLDriver } from 'kysely_deno_postgres';
|
import { PostgreSQLDriver } from 'kysely_deno_postgres';
|
||||||
|
|
||||||
|
import { Conf } from '@/config.ts';
|
||||||
import { DittoTables } from '@/db/DittoTables.ts';
|
import { DittoTables } from '@/db/DittoTables.ts';
|
||||||
|
|
||||||
export class DittoPostgres {
|
export class DittoPostgres {
|
||||||
|
@ -18,7 +19,7 @@ export class DittoPostgres {
|
||||||
createDriver() {
|
createDriver() {
|
||||||
return new PostgreSQLDriver(
|
return new PostgreSQLDriver(
|
||||||
{ connectionString: Deno.env.get('DATABASE_URL') },
|
{ connectionString: Deno.env.get('DATABASE_URL') },
|
||||||
navigator.hardwareConcurrency,
|
Conf.pg.poolSize,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
createIntrospector(db: Kysely<unknown>) {
|
createIntrospector(db: Kysely<unknown>) {
|
||||||
|
|
Loading…
Reference in New Issue