Добавлен connManager для управления пулами соединений к базам Sqlite, попутный рефакторинг

This commit is contained in:
Book Pauk
2019-03-08 16:50:44 +07:00
parent c7abae10b7
commit a39626f867
7 changed files with 59 additions and 23 deletions

View File

@@ -0,0 +1,26 @@
const SqliteConnectionPool = require('./SqliteConnectionPool');
class ConnManager {
constructor() {
this._pool = {};
}
async init(config) {
this.config = config;
for (const poolConfig of this.config.db) {
const dbFileName = this.config.dataDir + '/' + poolConfig.fileName;
const connPool = new SqliteConnectionPool();
await connPool.open(poolConfig.connCount, dbFileName);
this._pool[poolConfig.poolName] = connPool;
}
}
get pool() {
return this._pool;
}
}
const connManager = new ConnManager();
module.exports = connManager;