mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
add poolsize and availableconnections metrics back
This commit is contained in:
parent
a804608afb
commit
3495092eff
2 changed files with 18 additions and 3 deletions
|
|
@ -39,14 +39,14 @@ export class DittoDB {
|
|||
|
||||
static get poolSize(): number {
|
||||
if (Conf.db.dialect === 'postgres') {
|
||||
return DittoPostgres.getPool().size;
|
||||
return DittoPostgres.poolSize;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static get availableConnections(): number {
|
||||
if (Conf.db.dialect === 'postgres') {
|
||||
return DittoPostgres.getPool().available;
|
||||
return DittoPostgres.availableConnections;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,18 @@ import { KyselyLogger } from '@/db/KyselyLogger.ts';
|
|||
|
||||
export class DittoPostgres {
|
||||
static db: Kysely<DittoTables> | undefined;
|
||||
static postgres: postgres.Sql;
|
||||
|
||||
// deno-lint-ignore require-await
|
||||
static async getInstance(): Promise<Kysely<DittoTables>> {
|
||||
if (!this.postgres) {
|
||||
this.postgres = postgres(Conf.databaseUrl, { max: Conf.pg.poolSize }) as any;
|
||||
}
|
||||
|
||||
if (!this.db) {
|
||||
this.db = new Kysely({
|
||||
dialect: new PostgresJSDialect({
|
||||
postgres: postgres(Conf.databaseUrl) as any,
|
||||
postgres: this.postgres,
|
||||
}),
|
||||
log: KyselyLogger,
|
||||
});
|
||||
|
|
@ -22,4 +27,14 @@ export class DittoPostgres {
|
|||
|
||||
return this.db;
|
||||
}
|
||||
|
||||
static get poolSize() {
|
||||
return Conf.pg.poolSize;
|
||||
}
|
||||
|
||||
static get availableConnections(): number {
|
||||
// blocked by https://github.com/porsager/postgres/pull/911
|
||||
// return this.postgres.availableConnections;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue