mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-10-30 02:12:32 +00:00
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
//
|
|
// Created by stephane bourque on 2022-10-26.
|
|
//
|
|
|
|
#include "framework/EventBusManager.h"
|
|
#include "framework/KafkaManager.h"
|
|
#include "framework/MicroServiceFuncs.h"
|
|
#include "framework/utils.h"
|
|
|
|
namespace OpenWifi {
|
|
|
|
EventBusManager::EventBusManager(Poco::Logger &L) : Logger_(L) {}
|
|
|
|
void EventBusManager::run() {
|
|
Running_ = true;
|
|
Utils::SetThreadName("fmwk:EventMgr");
|
|
auto Msg = std::make_shared<std::string>(MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_JOIN));
|
|
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
|
|
false);
|
|
while (Running_) {
|
|
Poco::Thread::trySleep((unsigned long)MicroServiceDaemonBusTimer());
|
|
if (!Running_)
|
|
break;
|
|
Msg = std::make_shared<std::string>(MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE));
|
|
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(),
|
|
Msg, false);
|
|
}
|
|
Msg = std::make_shared<std::string>(MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_LEAVE));
|
|
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
|
|
false);
|
|
};
|
|
|
|
void EventBusManager::Start() {
|
|
poco_information(Logger(), "Starting...");
|
|
if (KafkaManager()->Enabled()) {
|
|
Thread_.start(*this);
|
|
}
|
|
}
|
|
|
|
void EventBusManager::Stop() {
|
|
if (KafkaManager()->Enabled()) {
|
|
poco_information(Logger(), "Stopping...");
|
|
Running_ = false;
|
|
Thread_.wakeUp();
|
|
Thread_.join();
|
|
poco_information(Logger(), "Stopped...");
|
|
}
|
|
}
|
|
|
|
} // namespace OpenWifi
|