General service-agnostic implemention of simple connection pool in TypeScript.
npm install
npm run build
import ConnectionPool from 'connection-pool';
const getNewConnection = () => new Promise(...);
const pool = new ConnectionsPool(5, getNewConnection);
(async function () {
try {
const connection = await pool.getConnection();
// some operations
connection.release();
} catch (e) {
console.log(e);
} finally {
pool.close();
}
})();
- Add unit tests
- Make
ConnectionPool
to emit events after connection was established, acquired and etc.
This project is licensed under the MIT License.