Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: brianc/node-postgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: psq/node-postgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 11, 2013

  1. stats function

    Pascal committed Jan 11, 2013
    Copy the full SHA
    f676527 View commit details
  2. removed logs that kill upstream tests

    Pascal committed Jan 11, 2013
    Copy the full SHA
    789a90b View commit details
Showing with 19 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +18 −1 lib/index.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ node_modules/
*.log
.lock-wscript
build/
.DS_Store
19 changes: 18 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -42,11 +42,15 @@ PG.prototype.connect = function(config, callback) {
var poolName = typeof(c) === 'string' ? c : c.user+c.host+c.port+c.database;
var pool = pools[poolName];

if(pool) return pool.acquire(cb);
if(pool) {
// console.log("pg: pool:", pool.getName(), pool.getPoolSize(), pool.availableObjectsCount(), pool.waitingClientsCount());
return pool.acquire(cb);
}

var pool = pools[poolName] = genericPool.Pool({
name: poolName,
create: function(callback) {
// console.log("pg: create connection");
var client = new self.Client(c);
client.connect(function(err) {
if(err) return callback(err);
@@ -66,6 +70,7 @@ PG.prototype.connect = function(config, callback) {
});
},
destroy: function(client) {
// console.log("pg: destroy connection");
client.end();
},
max: defaults.poolSize,
@@ -95,3 +100,15 @@ module.exports.__defineGetter__("native", function() {
});

module.exports.types = require('./types');

module.exports.stats = function(config) {
var pool = pools[config];
if (pool) {
return {
size: pool.getPoolSize(),
available: pool.availableObjectsCount(),
waiting: pool.waitingClientsCount()
}
}
return null;
}