feat(Firebird SQL): connections pool

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

12
package-lock.json generated
View File

@ -26,7 +26,7 @@
"marked": "~4.0.19",
"moment": "~2.29.4",
"mysql2": "~2.3.2",
"node-firebird": "github:Fabio286/node-firebird",
"node-firebird": "~1.1.3",
"pg": "~8.7.1",
"pg-connection-string": "~2.5.0",
"pg-query-stream": "~4.2.3",
@ -11284,8 +11284,9 @@
}
},
"node_modules/node-firebird": {
"version": "1.1.2",
"resolved": "git+ssh://git@github.com/Fabio286/node-firebird.git#28059a4aff44fc4b9ce69699bb1ad14f837de692",
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/node-firebird/-/node-firebird-1.1.3.tgz",
"integrity": "sha512-3VhiP8XMqlKQo8H8nPOmrqYFseEj0uUdoacZ5xutRAOFzLWR9ImXBfVLUdg4AiH34YCshgiU8Lc37AAX3Vc6YQ==",
"dependencies": {
"big-integer": "^1.6.48",
"long": "^4.0.0"
@ -25361,8 +25362,9 @@
}
},
"node-firebird": {
"version": "git+ssh://git@github.com/Fabio286/node-firebird.git#28059a4aff44fc4b9ce69699bb1ad14f837de692",
"from": "node-firebird@https://github.com/Fabio286/node-firebird",
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/node-firebird/-/node-firebird-1.1.3.tgz",
"integrity": "sha512-3VhiP8XMqlKQo8H8nPOmrqYFseEj0uUdoacZ5xutRAOFzLWR9ImXBfVLUdg4AiH34YCshgiU8Lc37AAX3Vc6YQ==",
"requires": {
"big-integer": "^1.6.48",
"long": "^4.0.0"

View File

@ -135,7 +135,7 @@
"marked": "~4.0.19",
"moment": "~2.29.4",
"mysql2": "~2.3.2",
"node-firebird": "github:Fabio286/node-firebird",
"node-firebird": "~1.1.3",
"pg": "~8.7.1",
"pg-connection-string": "~2.5.0",
"pg-query-stream": "~4.2.3",

View File

@ -43,7 +43,10 @@ export class FirebirdSQLClient extends AntaresCore {
}
async connect () {
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();