Fix error handling for GetSubscriptionTypes()

This commit is contained in:
Michael Friedrich 2018-06-28 17:38:32 +02:00
parent 50d83e850f
commit c5e913dfd4
2 changed files with 13 additions and 5 deletions

View File

@ -186,11 +186,12 @@ void RedisWriter::UpdateSubscriptions()
RedisSubscriptionInfo rsi;
String key = keysReply->element[i]->str;
if (!RedisWriter::GetSubscriptionTypes(key, rsi))
if (!RedisWriter::GetSubscriptionTypes(key, rsi)) {
Log(LogInformation, "RedisWriter")
<< "Subscription \"" << key<< "\" has no types listed.";
else
<< "Subscription \"" << key << "\" has no types listed.";
} else {
m_Subscriptions[key.SubStr(keyPrefix.GetLength())] = rsi;
}
}
} while (cursor != 0);
@ -198,12 +199,15 @@ void RedisWriter::UpdateSubscriptions()
<< "Current Redis event subscriptions: " << m_Subscriptions.size();
}
int RedisWriter::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi)
bool RedisWriter::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi)
{
try {
std::shared_ptr<redisReply> redisReply = ExecuteQuery({ "SMEMBERS", key });
VERIFY(redisReply->type == REDIS_REPLY_ARRAY);
if (redisReply->elements == 0)
return false;
for (size_t j = 0; j < redisReply->elements; j++) {
rsi.EventTypes.insert(redisReply->element[j]->str);
}
@ -214,7 +218,11 @@ int RedisWriter::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi)
} catch (const std::exception& ex) {
Log(LogWarning, "RedisWriter")
<< "Invalid Redis subscriber info for subscriber '" << key << "': " << DiagnosticInformation(ex);
return false;
}
return true;
}
void RedisWriter::PublishStatsTimerHandler(void)

View File

@ -60,7 +60,7 @@ private:
void UpdateSubscriptionsTimerHandler();
void UpdateSubscriptions();
int GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi);
bool GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi);
void PublishStatsTimerHandler();
void PublishStats();