Introduce IcingaDB::AddKvsToMap()

This commit is contained in:
Alexander A. Klimov 2022-04-19 13:19:54 +02:00
parent 2c3d2f8b87
commit 8eef51afeb
2 changed files with 17 additions and 12 deletions

View File

@ -230,18 +230,7 @@ void IcingaDB::UpdateAllConfigObjects()
"HSCAN", configCheckSum, cursor, "COUNT", "1000"
}, Prio::Config);
Array::Ptr kvs = res->Get(1);
Value* key = nullptr;
ObjectLock oLock (kvs);
for (auto& kv : kvs) {
if (key) {
redisCheckSums.emplace(std::move(*key), std::move(kv));
key = nullptr;
} else {
key = &kv;
}
}
AddKvsToMap(res->Get(1), redisCheckSums);
cursor = res->Get(0);
} while (cursor != "0");

View File

@ -45,6 +45,22 @@ public:
String GetEnvironmentId() const override;
template<class T>
static void AddKvsToMap(const Array::Ptr& kvs, T& map)
{
Value* key = nullptr;
ObjectLock oLock (kvs);
for (auto& kv : kvs) {
if (key) {
map.emplace(std::move(*key), std::move(kv));
key = nullptr;
} else {
key = &kv;
}
}
}
protected:
void ValidateTlsProtocolmin(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
void ValidateConnectTimeout(const Lazy<double>& lvalue, const ValidationUtils& utils) override;