Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@dmitriym09/tedious-connection-pool
Advanced tools
Connection Pool for tedious. Fork by dmitriym09
A connection pool for tedious.
npm install tedious-connection-pool
The only difference from the regular tedious API is how the connection is obtained and released. Rather than creating a connection and then closing it when finished, acquire a connection from the pool and release it when finished. Releasing resets the connection and makes in available for another use.
Once the Tedious Connection object has been acquired, the tedious API can be used with the connection as normal.
var ConnectionPool = require('tedious-connection-pool');
var Request = require('tedious').Request;
var poolConfig = {
min: 2,
max: 4,
log: true
};
var connectionConfig = {
userName: 'login',
password: 'password',
server: 'localhost'
};
//create the pool
var pool = new ConnectionPool(poolConfig, connectionConfig);
pool.on('error', function(err) {
console.error(err);
});
//acquire a connection
pool.acquire(function (err, connection) {
if (err) {
console.error(err);
return;
}
//use the connection as normal
var request = new Request('select 42', function(err, rowCount) {
if (err) {
console.error(err);
return;
}
console.log('rowCount: ' + rowCount);
//release the connection back to the pool when finished
connection.release();
});
request.on('row', function(columns) {
console.log('value: ' + columns[0].value);
});
connection.execSql(request);
});
When you are finished with the pool, you can drain it (close all connections).
pool.drain();
poolConfig
{Object} the pool configuration object
min
{Number} The minimum of connections there can be in the pool. Default = 10
max
{Number} The maximum number of connections there can be in the pool. Default = 50
idleTimeout
{Number} The number of milliseconds before closing an unused connection. Default = 300000
retryDelay
{Number} The number of milliseconds to wait after a connection fails, before trying again. Default = 5000
acquireTimeout
{Number} The number of milliseconds to wait for a connection, before returning an error. Default = 60000
log
{Boolean|Function} Set to true to have debug log written to the console or pass a function to receive the log messages. Default = undefined
connectionConfig
{Object} The same configuration that would be used to create a
tedious Connection.Acquire a Tedious Connection object from the pool.
callback(err, connection)
{Function} Callback functionerr
{Object} An Error object is an error occurred trying to acquire a connection, otherwise null.connection
{Object} A ConnectionClose all pooled connections and stop making new ones. The pool should be discarded after it has been drained.
callback()
{Function} Callback functionThe 'error' event is emitted when a connection fails to connect to the SQL Server. The pool will simply retry indefinitely. The application may want to handle errors in a more nuanced way.
The following method is added to the Tedious Connection object.
Release the connect back to the pool to be used again
FAQs
Connection Pool for tedious. Fork by dmitriym09
We found that @dmitriym09/tedious-connection-pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.