mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-10-29 09:52:29 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -33,6 +33,17 @@ namespace OpenWifi {
|
||||
|
||||
void MicroService::Exit(int Reason) { std::exit(Reason); }
|
||||
|
||||
static std::string MakeServiceListString(const Types::MicroServiceMetaMap &Services) {
|
||||
std::string SvcList;
|
||||
for (const auto &Svc : Services) {
|
||||
if (SvcList.empty())
|
||||
SvcList = Svc.second.Type;
|
||||
else
|
||||
SvcList += ", " + Svc.second.Type;
|
||||
}
|
||||
return SvcList;
|
||||
}
|
||||
|
||||
void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key,
|
||||
const std::string &Payload) {
|
||||
std::lock_guard G(InfraMutex_);
|
||||
@@ -84,15 +95,16 @@ namespace OpenWifi {
|
||||
.toString(),
|
||||
.LastUpdate = Utils::Now()};
|
||||
|
||||
auto s1 = MakeServiceListString(Services_);
|
||||
Services_[PrivateEndPoint] = ServiceInfo;
|
||||
if(Event == KafkaTopics::ServiceEvents::EVENT_JOIN) {
|
||||
poco_information(
|
||||
poco_information(
|
||||
logger(),
|
||||
fmt::format(
|
||||
"Service {} ID={} is joining the system.",
|
||||
"Service {} ID={} is joining the system. old={}",
|
||||
Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE)
|
||||
.toString(),
|
||||
ID));
|
||||
ID, s1));
|
||||
std::string SvcList;
|
||||
for (const auto &Svc : Services_) {
|
||||
if (SvcList.empty())
|
||||
@@ -135,13 +147,19 @@ namespace OpenWifi {
|
||||
|
||||
auto ServiceHint = Services_.begin();
|
||||
auto now = Utils::Now();
|
||||
auto si1 = Services_.size();
|
||||
auto ss1 = MakeServiceListString(Services_);
|
||||
while(ServiceHint!=Services_.end()) {
|
||||
if ((now - ServiceHint->second.LastUpdate) > 120) {
|
||||
poco_information(logger(), fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint));
|
||||
poco_information(Logger_, fmt::format("ZombieService: Removing service {}, ", ServiceHint->second.PublicEndPoint));
|
||||
ServiceHint = Services_.erase(ServiceHint);
|
||||
} else
|
||||
++ServiceHint;
|
||||
}
|
||||
if(Services_.size() != si1) {
|
||||
auto ss2 = MakeServiceListString(Services_);
|
||||
poco_information(Logger_, fmt::format("Current list of microservices: {} -> {}", ss1, ss2));
|
||||
}
|
||||
|
||||
} catch (const Poco::Exception &E) {
|
||||
logger().log(E);
|
||||
|
||||
Reference in New Issue
Block a user