mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Clean up copy-in internal API
This commit is contained in:
parent
1688567340
commit
99f9492c72
@ -107,22 +107,22 @@ Client.prototype.connect = function(callback) {
|
||||
});
|
||||
|
||||
con.on('copyInResponse', function(msg) {
|
||||
self.activeQuery.streamData(self.connection);
|
||||
self.activeQuery.handleCopyInResponse(self.connection);
|
||||
});
|
||||
|
||||
con.on('copyOutResponse', function(msg) {
|
||||
if(self.activeQuery.stream === undefined) {
|
||||
self.activeQuery._canceledDueToError =
|
||||
new Error('No destination stream defined');
|
||||
if(self.activeQuery.stream === undefined) {
|
||||
self.activeQuery._canceledDueToError = new Error('No destination stream defined');
|
||||
//canceling query requires creation of new connection
|
||||
//look for postgres frontend/backend protocol
|
||||
//TODO - this needs to die/be refactored
|
||||
(new self.constructor({port: self.port, host: self.host}))
|
||||
.cancel(self, self.activeQuery);
|
||||
}
|
||||
});
|
||||
|
||||
con.on('copyData', function (msg) {
|
||||
self.activeQuery.handleCopyFromChunk(msg.chunk);
|
||||
self.activeQuery.handleCopyData(msg, self.connection);
|
||||
});
|
||||
|
||||
con.on('notification', function(msg) {
|
||||
|
||||
@ -170,12 +170,13 @@ Query.prototype.prepare = function(connection) {
|
||||
this._getRows(connection, this.rows);
|
||||
};
|
||||
|
||||
Query.prototype.streamData = function (connection) {
|
||||
Query.prototype.handleCopyInResponse = function (connection) {
|
||||
if(this.stream) this.stream.startStreamingToConnection(connection);
|
||||
else connection.sendCopyFail('No source stream defined');
|
||||
};
|
||||
|
||||
Query.prototype.handleCopyFromChunk = function (chunk) {
|
||||
Query.prototype.handleCopyData = function (msg, connection) {
|
||||
var chunk = msg.chunk;
|
||||
if(this.stream) {
|
||||
this.stream.handleChunk(chunk);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user