mirror of
https://github.com/Fabio286/antares.git
synced 2025-04-23 06:27:21 +02:00
feat(Firebird SQL): connections pool
This commit is contained in:
parent
e6f6a022d1
commit
76df6319c2
12
package-lock.json
generated
12
package-lock.json
generated
@ -26,7 +26,7 @@
|
|||||||
"marked": "~4.0.19",
|
"marked": "~4.0.19",
|
||||||
"moment": "~2.29.4",
|
"moment": "~2.29.4",
|
||||||
"mysql2": "~2.3.2",
|
"mysql2": "~2.3.2",
|
||||||
"node-firebird": "github:Fabio286/node-firebird",
|
"node-firebird": "~1.1.3",
|
||||||
"pg": "~8.7.1",
|
"pg": "~8.7.1",
|
||||||
"pg-connection-string": "~2.5.0",
|
"pg-connection-string": "~2.5.0",
|
||||||
"pg-query-stream": "~4.2.3",
|
"pg-query-stream": "~4.2.3",
|
||||||
@ -11284,8 +11284,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/node-firebird": {
|
"node_modules/node-firebird": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"resolved": "git+ssh://git@github.com/Fabio286/node-firebird.git#28059a4aff44fc4b9ce69699bb1ad14f837de692",
|
"resolved": "https://registry.npmjs.org/node-firebird/-/node-firebird-1.1.3.tgz",
|
||||||
|
"integrity": "sha512-3VhiP8XMqlKQo8H8nPOmrqYFseEj0uUdoacZ5xutRAOFzLWR9ImXBfVLUdg4AiH34YCshgiU8Lc37AAX3Vc6YQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"big-integer": "^1.6.48",
|
"big-integer": "^1.6.48",
|
||||||
"long": "^4.0.0"
|
"long": "^4.0.0"
|
||||||
@ -25361,8 +25362,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node-firebird": {
|
"node-firebird": {
|
||||||
"version": "git+ssh://git@github.com/Fabio286/node-firebird.git#28059a4aff44fc4b9ce69699bb1ad14f837de692",
|
"version": "1.1.3",
|
||||||
"from": "node-firebird@https://github.com/Fabio286/node-firebird",
|
"resolved": "https://registry.npmjs.org/node-firebird/-/node-firebird-1.1.3.tgz",
|
||||||
|
"integrity": "sha512-3VhiP8XMqlKQo8H8nPOmrqYFseEj0uUdoacZ5xutRAOFzLWR9ImXBfVLUdg4AiH34YCshgiU8Lc37AAX3Vc6YQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"big-integer": "^1.6.48",
|
"big-integer": "^1.6.48",
|
||||||
"long": "^4.0.0"
|
"long": "^4.0.0"
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
"marked": "~4.0.19",
|
"marked": "~4.0.19",
|
||||||
"moment": "~2.29.4",
|
"moment": "~2.29.4",
|
||||||
"mysql2": "~2.3.2",
|
"mysql2": "~2.3.2",
|
||||||
"node-firebird": "github:Fabio286/node-firebird",
|
"node-firebird": "~1.1.3",
|
||||||
"pg": "~8.7.1",
|
"pg": "~8.7.1",
|
||||||
"pg-connection-string": "~2.5.0",
|
"pg-connection-string": "~2.5.0",
|
||||||
"pg-query-stream": "~4.2.3",
|
"pg-query-stream": "~4.2.3",
|
||||||
|
@ -43,7 +43,10 @@ export class FirebirdSQLClient extends AntaresCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async connect () {
|
async connect () {
|
||||||
this._connection = await this.getConnection();
|
if (!this._poolSize)
|
||||||
|
this._connection = await this.getConnection();
|
||||||
|
else
|
||||||
|
this._connection = await this.getConnectionPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getConnection () {
|
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 () {
|
destroy () {
|
||||||
return this._connection.detach();
|
return (this._connection as firebird.Database).detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
use (): void {
|
use (): void {
|
||||||
@ -726,6 +739,7 @@ export class FirebirdSQLClient extends AntaresCore {
|
|||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
this._connection.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
timeStop = new Date();
|
timeStop = new Date();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user