diff --git a/index.js b/lib/connection-pool.js similarity index 81% rename from index.js rename to lib/connection-pool.js index 9b68c36..db2a67e 100644 --- a/index.js +++ b/lib/connection-pool.js @@ -1,5 +1,4 @@ -var Connection = require('tedious').Connection; -var util = require('util'); +var PooledConnection = require('./pooled-connection'); var connectionEventNames = [ 'connect', @@ -13,22 +12,6 @@ var connectionEventNames = [ 'secure' ]; -function PooledConnection(pool, config) { - Connection.call(this, config); - this.pool = pool; -} - -util.inherits(PooledConnection, Connection); - -PooledConnection.prototype.close = function() { - this.emit('end'); - this.pool.returnConnectionToPool(this); -} - -PooledConnection.prototype._close = function() { - Connection.prototype.close.call(this); -} - function ConnectionPool(poolConfig, connectionConfig) { var pool = this; diff --git a/lib/pooled-connection.js b/lib/pooled-connection.js new file mode 100644 index 0000000..c595d43 --- /dev/null +++ b/lib/pooled-connection.js @@ -0,0 +1,20 @@ +var Connection = require('tedious').Connection; +var util = require('util'); + +function PooledConnection(pool, config) { + Connection.call(this, config); + this.pool = pool; +} + +util.inherits(PooledConnection, Connection); + +PooledConnection.prototype.close = function() { + this.emit('end'); + this.pool.returnConnectionToPool(this); +} + +PooledConnection.prototype._close = function() { + Connection.prototype.close.call(this); +} + +module.exports = PooledConnection; diff --git a/package.json b/package.json index 47c623b..877e8f7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "tedious-connection-pool", "version": "0.0.1", "description": "Connection Pool for tedious.", - "main": "index.js", + "main": "lib/connection-pool.js", "scripts": { "test": "test" }, diff --git a/test/connection-pool.test.js b/test/connection-pool.test.js index 09e712f..10c5b0a 100644 --- a/test/connection-pool.test.js +++ b/test/connection-pool.test.js @@ -1,6 +1,6 @@ var assert = require('assert') var async = require('async') -var ConnectionPool = require('../index'); +var ConnectionPool = require('../lib/connection-pool'); var Request = require('tedious').Request; var connectionConfig = {