RedisWriter: identify config objects by SHA1(PackObject([Environment, __name]))

This commit is contained in:
Alexander A. Klimov 2018-06-22 15:55:19 +02:00 committed by Michael Friedrich
parent fae5b88e48
commit 4eee9572ab
3 changed files with 10 additions and 5 deletions

View File

@ -43,11 +43,6 @@ void RedisWriter::ConfigStaticInitialize()
ConfigObject::OnVersionChanged.connect(std::bind(&RedisWriter::VersionChangedHandler, _1));
}
static inline String GetIdentifier(const ConfigObject::Ptr& object)
{
return object->GetName();
}
void RedisWriter::UpdateAllConfigObjects(void)
{
AssertOnWorkQueue();

View File

@ -25,6 +25,8 @@
#include "base/tlsutility.hpp"
#include "base/initialize.hpp"
#include "base/objectlock.hpp"
#include "base/array.hpp"
#include "base/scriptglobal.hpp"
using namespace icinga;
@ -37,6 +39,13 @@ String RedisWriter::FormatCheckSumBinary(const String& str)
return output;
}
static Value l_DefaultEnv = "production";
String RedisWriter::GetIdentifier(const ConfigObject::Ptr& object)
{
return HashValue((Array::Ptr)new Array({ScriptGlobal::Get("Environment", &l_DefaultEnv), object->GetName()}));
}
String RedisWriter::CalculateCheckSumString(const String& str)
{
return SHA1(str);

View File

@ -77,6 +77,7 @@ private:
/* utilities */
static String FormatCheckSumBinary(const String& str);
static String GetIdentifier(const ConfigObject::Ptr& object);
static String CalculateCheckSumString(const String& str);
static String CalculateCheckSumGroups(const Array::Ptr& groups);
static String CalculateCheckSumProperties(const ConfigObject::Ptr& object, const std::set<String>& propertiesBlacklist);