1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat(Firebird SQL): connections pool

This commit is contained in:
2022-11-07 09:49:36 +01:00
parent e6f6a022d1
commit 76df6319c2
3 changed files with 24 additions and 8 deletions

View File

@ -43,7 +43,10 @@ export class FirebirdSQLClient extends AntaresCore {
}
async connect () {
this._connection = await this.getConnection();
if (!this._poolSize)
this._connection = await this.getConnection();
else
this._connection = await this.getConnectionPool();
}
async getConnection () {
@ -55,8 +58,18 @@ export class FirebirdSQLClient extends AntaresCore {
});
}
async getConnectionPool () {
const pool = firebird.pool(this._poolSize, { ...this._params, blobAsText: true });
return new Promise<firebird.Database>((resolve, reject) => {
pool.get((err, db) => {
if (err) reject(err);
else resolve(db);
});
});
}
destroy () {
return this._connection.detach();
return (this._connection as firebird.Database).detach();
}
use (): void {
@ -726,6 +739,7 @@ export class FirebirdSQLClient extends AntaresCore {
}
catch (err) {
reject(err);
this._connection.detach();
}
timeStop = new Date();