Better indication that pg.pools is a private api

This commit is contained in:
brianc 2016-06-21 22:03:25 -05:00
parent 0aa62f2854
commit 406357b9c6

View File

@ -12,7 +12,7 @@ var PG = function(clientConstructor) {
this.Client = clientConstructor;
this.Query = this.Client.Query;
this.Pool = Pool;
this.pools = [];
this._pools = [];
this.Connection = Connection;
this.types = require('pg-types');
};
@ -21,14 +21,14 @@ util.inherits(PG, EventEmitter);
PG.prototype.end = function() {
var self = this;
var keys = Object.keys(this.pools);
var keys = Object.keys(this._pools);
var count = keys.length;
if(count === 0) {
self.emit('end');
} else {
keys.forEach(function(key) {
var pool = self.pools[key];
delete self.pools[key];
var pool = self._pools[key];
delete self._pools[key];
pool.pool.drain(function() {
pool.pool.destroyAllNow(function() {
count--;
@ -58,8 +58,8 @@ PG.prototype.connect = function(config, callback) {
config.idleTimeoutMillis = config.idleTimeoutMillis || config.poolIdleTimeout || defaults.poolIdleTimeout;
config.log = config.log || config.poolLog || defaults.poolLog;
this.pools[poolName] = this.pools[poolName] || new Pool(config, this.Client);
var pool = this.pools[poolName];
this._pools[poolName] = this._pools[poolName] || new Pool(config, this.Client);
var pool = this._pools[poolName];
pool.connect(callback);
if(!pool.listeners('error').length) {
//propagate errors up to pg object