| 231 | } |
| 232 | |
| 233 | ananas::Future<std::pair<bool, std::string>> AFCNetServiceManagerModule::RegisterToConsul(const int bus_id) |
| 234 | { |
| 235 | auto reg_center = m_pBusModule->GetRegCenter(); |
| 236 | AFBusAddr bus(bus_id); |
| 237 | auto bus_name = bus.ToString(); |
| 238 | |
| 239 | const std::string app_whole_name = m_pBusModule->GetAppWholeName(bus.bus_id); |
| 240 | const std::string app_name = m_pBusModule->GetAppName(static_cast<ARK_APP_TYPE>(bus.app_type)); |
| 241 | |
| 242 | const AFProcConfig& self_proc = m_pBusModule->GetSelfProc(); |
| 243 | |
| 244 | consul::service_data service; |
| 245 | service.set_id(app_whole_name); |
| 246 | service.set_name(reg_center.service_name); |
| 247 | service.set_address(self_proc.intranet_ep.GetIP()); |
| 248 | service.set_port(self_proc.intranet_ep.GetPort()); |
| 249 | |
| 250 | // multi-tag |
| 251 | service.add_tags(app_name); |
| 252 | service.add_tags(bus_name); |
| 253 | |
| 254 | // multi-meta |
| 255 | service.mutable_meta()->insert({"busid", bus_name}); |
| 256 | |
| 257 | // health check |
| 258 | auto check = service.mutable_check(); |
| 259 | check->set_id(app_whole_name + "_check"); |
| 260 | check->set_name(app_whole_name); |
| 261 | check->set_tcp(self_proc.intranet_ep.GetIP() + ":" + ARK_TO_STRING(self_proc.intranet_ep.GetPort())); |
| 262 | check->set_interval(reg_center.check_interval); |
| 263 | check->set_timeout(reg_center.check_timeout); |
| 264 | |
| 265 | return m_pConsulModule->RegisterService(service); |
| 266 | } |
| 267 | |
| 268 | int AFCNetServiceManagerModule::DeregisterFromConsul(const int bus_id) |
| 269 | { |
nothing calls this directly
no test coverage detected