Skip to content

Commit d3c01b1

Browse files
author
Kibae Shin
committed
Support for logical/streaming replication mode
1 parent 71a1364 commit d3c01b1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/client.js

Lines changed: 4 additions & 0 deletions
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 === true ? 'true' : params.replication;
228+
}
225229

226230
return data;
227231
};

lib/connection-parameters.js

Lines changed: 4 additions & 0 deletions
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

@@ -82,6 +83,9 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
8283
if(this.database) {
8384
params.push("dbname='" + this.database + "'");
8485
}
86+
if(this.replication) {
87+
params.push("replication='" + (this.database === true ? "true" : this.replication) + "'");
88+
}
8589
if(this.host) {
8690
params.push("host=" + this.host);
8791
}

0 commit comments

Comments
 (0)