forked from tediousjs/tedious-connection-pool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a placeholder ConnectionPool class, that doesn't do much yet.
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var Connection = require('tedious').Connection; | ||
var util = require('util'); | ||
|
||
function PooledConnection(config) { | ||
Connection.call(this, config); | ||
} | ||
|
||
util.inherits(PooledConnection, Connection); | ||
|
||
PooledConnection.prototype.close = function() { | ||
this._close(); | ||
} | ||
|
||
PooledConnection.prototype._close = function() { | ||
Connection.prototype.close.call(this); | ||
} | ||
|
||
function ConnectionPool(config) { | ||
return { | ||
getConnection: function() { | ||
return new PooledConnection(config); | ||
} | ||
}; | ||
}; | ||
|
||
module.exports = ConnectionPool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var assert = require('assert') | ||
var ConnectionPool = require('../index'); | ||
|
||
var config = { | ||
userName: 'test', | ||
password: 'test', | ||
server: '192.168.1.212', | ||
}; | ||
|
||
describe('ConnectionPool', function() { | ||
describe('one connection', function() { | ||
it('should connect', function(done) { | ||
|
||
// var connection = new Connection(config); | ||
|
||
// connection.on('connect', function(err) { | ||
// done(); | ||
// }); | ||
|
||
var cp = new ConnectionPool(config); | ||
var connection = cp.getConnection(); | ||
// console.log(connection); | ||
|
||
connection.on('connect', function(err) { | ||
connection.close(); | ||
}); | ||
|
||
connection.on('end', function(err) { | ||
console.log('end') | ||
done(); | ||
}); | ||
}) | ||
}) | ||
}) |