MCPcopy Create free account
hub / github.com/Tencent/phxsql / GetDestEndpoint

Method GetDestEndpoint

phxsqlproxy/io_router.cpp:116–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116int MasterIORouter::GetDestEndpoint(std::string & dest_ip, int & dest_port) {
117 int ret = 0;
118 dest_ip = "";
119 std::string master_ip = "";
120
121 ret = group_status_cache_->GetMaster(master_ip);
122 if (ret != 0) {
123 LOG_ERR("getmaster failed, ret %d", ret);
124 return -__LINE__;
125 }
126
127 bool is_master = (master_ip == worker_config_->listen_ip_);
128 if (is_master) {
129 dest_ip = "127.0.0.1";
130 dest_port = config_->GetMysqlPort();
131 } else {
132 dest_ip = master_ip;
133 dest_port = config_->ProxyProtocol() ? worker_config_->proxy_port_ : worker_config_->port_;
134 }
135
136 LOG_DEBUG("dest ip [%s] port [%d]", dest_ip.c_str(), dest_port);
137 return 0;
138}
139
140SlaveIORouter::SlaveIORouter(PHXSqlProxyConfig * config,
141 WorkerConfig_t * worker_config,

Callers

nothing calls this directly

Calls 5

GetMysqlPortMethod · 0.80
ProxyProtocolMethod · 0.80
MasterEnableReadPortMethod · 0.80
GetSlaveMethod · 0.80
GetMasterMethod · 0.45

Tested by

no test coverage detected