Skip to content

Commit 4f790de

Browse files
Kibae Shinbrianc
Kibae Shin
authored andcommitted
Support for logical streaming replication (#1271)
* Support for logical streaming replication * Wrong compare expr in getLibpqConnectionString * Simplify codes for replication parameter
1 parent 4505ae9 commit 4f790de

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Diff for: lib/client.js

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var Client = function(config) {
2626
this.port = this.connectionParameters.port;
2727
this.host = this.connectionParameters.host;
2828
this.password = this.connectionParameters.password;
29+
this.replication = this.connectionParameters.replication;
2930

3031
var c = config || {};
3132

@@ -222,6 +223,9 @@ Client.prototype.getStartupConf = function() {
222223
if (appName) {
223224
data.application_name = appName;
224225
}
226+
if (params.replication) {
227+
data.replication = '' + params.replication;
228+
}
225229

226230
return data;
227231
};

Diff for: lib/connection-parameters.js

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var ConnectionParameters = function(config) {
5757
this.binary = val('binary', config);
5858
this.ssl = typeof config.ssl === 'undefined' ? useSsl() : config.ssl;
5959
this.client_encoding = val("client_encoding", config);
60+
this.replication = val("replication", config);
6061
//a domain socket begins with '/'
6162
this.isDomainSocket = (!(this.host||'').indexOf('/'));
6263

@@ -88,6 +89,9 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
8889
if(this.database) {
8990
params.push("dbname='" + this.database + "'");
9091
}
92+
if(this.replication) {
93+
params.push("replication='" + this.replication + "'");
94+
}
9195
if(this.host) {
9296
params.push("host=" + this.host);
9397
}

Diff for: lib/connection.js

+3
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ Connection.prototype.parseMessage = function(buffer) {
425425
case 0x48: //H
426426
return this.parseH(buffer, length);
427427

428+
case 0x57: //W
429+
return new Message('replicationStart', length);
430+
428431
case 0x63: //c
429432
return new Message('copyDone', length);
430433

0 commit comments

Comments
 (0)