Skip to content

Commit 99f9492

Browse files
committed
Clean up copy-in internal API
1 parent 1688567 commit 99f9492

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/client.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,22 @@ Client.prototype.connect = function(callback) {
107107
});
108108

109109
con.on('copyInResponse', function(msg) {
110-
self.activeQuery.streamData(self.connection);
110+
self.activeQuery.handleCopyInResponse(self.connection);
111111
});
112112

113113
con.on('copyOutResponse', function(msg) {
114-
if(self.activeQuery.stream === undefined) {
115-
self.activeQuery._canceledDueToError =
116-
new Error('No destination stream defined');
114+
if(self.activeQuery.stream === undefined) {
115+
self.activeQuery._canceledDueToError = new Error('No destination stream defined');
117116
//canceling query requires creation of new connection
118117
//look for postgres frontend/backend protocol
118+
//TODO - this needs to die/be refactored
119119
(new self.constructor({port: self.port, host: self.host}))
120120
.cancel(self, self.activeQuery);
121121
}
122122
});
123123

124124
con.on('copyData', function (msg) {
125-
self.activeQuery.handleCopyFromChunk(msg.chunk);
125+
self.activeQuery.handleCopyData(msg, self.connection);
126126
});
127127

128128
con.on('notification', function(msg) {

lib/query.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,13 @@ Query.prototype.prepare = function(connection) {
170170
this._getRows(connection, this.rows);
171171
};
172172

173-
Query.prototype.streamData = function (connection) {
173+
Query.prototype.handleCopyInResponse = function (connection) {
174174
if(this.stream) this.stream.startStreamingToConnection(connection);
175175
else connection.sendCopyFail('No source stream defined');
176176
};
177177

178-
Query.prototype.handleCopyFromChunk = function (chunk) {
178+
Query.prototype.handleCopyData = function (msg, connection) {
179+
var chunk = msg.chunk;
179180
if(this.stream) {
180181
this.stream.handleChunk(chunk);
181182
}

0 commit comments

Comments
 (0)