You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "git-hulk (via GitHub)" <gi...@apache.org> on 2023/03/09 07:55:16 UTC

[GitHub] [incubator-kvrocks] git-hulk commented on a diff in pull request #1303: Support replica-announce-ip and replica-announce-port

git-hulk commented on code in PR #1303:
URL: https://github.com/apache/incubator-kvrocks/pull/1303#discussion_r1130607885


##########
src/cluster/replication.cc:
##########
@@ -425,18 +425,35 @@ ReplicationThread::CBState ReplicationThread::checkDBNameReadCB(bufferevent *bev
 
 ReplicationThread::CBState ReplicationThread::replConfWriteCB(bufferevent *bev, void *ctx) {
   auto self = static_cast<ReplicationThread *>(ctx);
-  send_string(bev,
-              Redis::MultiBulkString({"replconf", "listening-port", std::to_string(self->srv_->GetConfig()->port)}));
+  auto config = self->srv_->GetConfig();
+
+  auto port = config->replica_announce_port > 0 ? config->replica_announce_port : config->port;
+  if (!self->next_try_without_announce_ip_address_ && !config->replica_announce_ip.empty()) {
+    send_string(bev, Redis::MultiBulkString({"replconf", "listening-port", std::to_string(port), "ip-address",
+                                             config->replica_announce_ip}));
+  } else {
+    send_string(bev, Redis::MultiBulkString({"replconf", "listening-port", std::to_string(port)}));

Review Comment:
   I think this place is fine since we are using this initialized vector style in many other places.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org