mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 07:04:37 +02:00
Only send events to Redis when there is at least one subscriber
refs #4991
This commit is contained in:
parent
10ddcbe4d3
commit
34c69d9556
@ -244,6 +244,21 @@ void RedisWriter::HandleEvent(const Dictionary::Ptr& event)
|
|||||||
if (!m_Context)
|
if (!m_Context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
String type = event->Get("type");
|
||||||
|
bool atLeastOneSubscriber = false;
|
||||||
|
|
||||||
|
for (const std::pair<String, RedisSubscriptionInfo>& kv : m_Subscriptions) {
|
||||||
|
const auto& rsi = kv.second;
|
||||||
|
|
||||||
|
if (rsi.EventTypes.find(type) == rsi.EventTypes.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
atLeastOneSubscriber = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!atLeastOneSubscriber)
|
||||||
|
return;
|
||||||
|
|
||||||
Log(LogInformation, "RedisWriter")
|
Log(LogInformation, "RedisWriter")
|
||||||
<< "Pushing event to Redis: '" << Value(event) << "'.";
|
<< "Pushing event to Redis: '" << Value(event) << "'.";
|
||||||
|
|
||||||
@ -318,8 +333,6 @@ void RedisWriter::HandleEvent(const Dictionary::Ptr& event)
|
|||||||
|
|
||||||
freeReplyObject(reply3);
|
freeReplyObject(reply3);
|
||||||
|
|
||||||
String type = event->Get("type");
|
|
||||||
|
|
||||||
for (const std::pair<String, RedisSubscriptionInfo>& kv : m_Subscriptions) {
|
for (const std::pair<String, RedisSubscriptionInfo>& kv : m_Subscriptions) {
|
||||||
const auto& name = kv.first;
|
const auto& name = kv.first;
|
||||||
const auto& rsi = kv.second;
|
const auto& rsi = kv.second;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user