remove pauseDrain/resumeDrain
This commit is contained in:
parent
aadb2917cc
commit
e93a4a5d66
@ -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();
|
||||
};
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user