From e93a4a5d669212fc51c9aff08f2530958c21a2eb Mon Sep 17 00:00:00 2001 From: brianc Date: Thu, 7 Mar 2013 16:12:09 -0600 Subject: [PATCH] remove pauseDrain/resumeDrain --- lib/client.js | 34 +-------------- test/unit/client/query-queue-tests.js | 60 --------------------------- 2 files changed, 1 insertion(+), 93 deletions(-) diff --git a/lib/client.js b/lib/client.js index 75c5035..4ab8cb5 100644 --- a/lib/client.js +++ b/lib/client.js @@ -205,13 +205,7 @@ Client.prototype._pulseQueryQueue = function() { this.activeQuery.submit(this.connection); } else if(this.hasExecuted) { this.activeQuery = null; - //TODO remove pauseDrain for v1.0 - if(this._drainPaused > 0) { - this._drainPaused++; - } - else { - this.emit('drain'); - } + this.emit('drain'); } } }; @@ -255,32 +249,6 @@ Client.prototype.query = function(config, values, callback) { return query; }; -//prevents client from otherwise emitting 'drain' event until 'resumeDrain' is -//called -Client.prototype.pauseDrain = function() { - deprecate('Client.prototype.pauseDrain is deprecated and will be removed it v1.0.0 (very soon)', - 'please see the following for more details:', - 'https://github.com/brianc/node-postgres/wiki/pg', - 'https://github.com/brianc/node-postgres/issues/227', - 'https://github.com/brianc/node-postgres/pull/274', - 'feel free to get in touch via github if you have questions'); - this._drainPaused = 1; -}; - -//resume raising 'drain' event -Client.prototype.resumeDrain = function() { - deprecate('Client.prototype.resumeDrain is deprecated and will be removed it v1.0.0 (very soon)', - 'please see the following for more details:', - 'https://github.com/brianc/node-postgres/wiki/pg', - 'https://github.com/brianc/node-postgres/issues/227', - 'https://github.com/brianc/node-postgres/pull/274', - 'feel free to get in touch via github if you have questions'); - if(this._drainPaused > 1) { - this.emit('drain'); - } - this._drainPaused = 0; -}; - Client.prototype.end = function() { this.connection.end(); }; diff --git a/test/unit/client/query-queue-tests.js b/test/unit/client/query-queue-tests.js index cd87cfe..62b38bd 100644 --- a/test/unit/client/query-queue-tests.js +++ b/test/unit/client/query-queue-tests.js @@ -50,63 +50,3 @@ test('drain', function() { }); }); }); - -test('with drain paused', function() { - //mock out a fake connection - var con = new Connection({stream: "NO"}); - con.connect = function() { - con.emit('connect'); - }; - con.query = function() { - }; - - var client = new Client({connection:con}); - - client.connect(); - - var drainCount = 0; - client.on('drain', function() { - drainCount++; - }); - - test('normally unpaused', function() { - con.emit('readyForQuery'); - client.query('boom'); - assert.emits(client, 'drain', function() { - assert.equal(drainCount, 1); - }); - con.emit('readyForQuery'); - }); - - test('pausing', function() { - test('unpaused with no queries in between', function() { - client.pauseDrain(); - client.resumeDrain(); - assert.equal(drainCount, 1); - }); - - test('paused', function() { - test('resumeDrain after empty', function() { - client.pauseDrain(); - client.query('asdf'); - con.emit('readyForQuery'); - assert.equal(drainCount, 1); - client.resumeDrain(); - assert.equal(drainCount, 2); - }); - - test('resumDrain while still pending', function() { - client.pauseDrain(); - client.query('asdf'); - client.query('asdf1'); - con.emit('readyForQuery'); - client.resumeDrain(); - assert.equal(drainCount, 2); - con.emit('readyForQuery'); - assert.equal(drainCount, 3); - }); - - }); - }); - -});