From 724ce1f172558f79d026b1a95c99b40f121525c6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 22 Jun 2018 16:18:22 +0200 Subject: [PATCH] RedisWriter: dump also environment_checksum (per config object) --- lib/redis/rediswriter-objects.cpp | 1 + lib/redis/rediswriter-utility.cpp | 7 ++++++- lib/redis/rediswriter.hpp | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/redis/rediswriter-objects.cpp b/lib/redis/rediswriter-objects.cpp index 8d889dd5b..27ad52bba 100644 --- a/lib/redis/rediswriter-objects.cpp +++ b/lib/redis/rediswriter-objects.cpp @@ -155,6 +155,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran Dictionary::Ptr checkSums = new Dictionary(); checkSums->Set("name_checksum", CalculateCheckSumString(object->GetShortName())); + checkSums->Set("environment_checksum", CalculateCheckSumString(GetEnvironment())); // TODO: move this elsewhere Checkable::Ptr checkable = dynamic_pointer_cast(object); diff --git a/lib/redis/rediswriter-utility.cpp b/lib/redis/rediswriter-utility.cpp index ac480274e..ad3a8b5ba 100644 --- a/lib/redis/rediswriter-utility.cpp +++ b/lib/redis/rediswriter-utility.cpp @@ -41,9 +41,14 @@ String RedisWriter::FormatCheckSumBinary(const String& str) static Value l_DefaultEnv = "production"; +String RedisWriter::GetEnvironment() +{ + return ScriptGlobal::Get("Environment", &l_DefaultEnv); +} + String RedisWriter::GetIdentifier(const ConfigObject::Ptr& object) { - return HashValue((Array::Ptr)new Array({ScriptGlobal::Get("Environment", &l_DefaultEnv), object->GetName()})); + return HashValue((Array::Ptr)new Array({GetEnvironment(), object->GetName()})); } String RedisWriter::CalculateCheckSumString(const String& str) diff --git a/lib/redis/rediswriter.hpp b/lib/redis/rediswriter.hpp index 7be55ace4..cc11a10e1 100644 --- a/lib/redis/rediswriter.hpp +++ b/lib/redis/rediswriter.hpp @@ -78,6 +78,7 @@ private: static String FormatCheckSumBinary(const String& str); static String GetIdentifier(const ConfigObject::Ptr& object); + static String GetEnvironment(); static String CalculateCheckSumString(const String& str); static String CalculateCheckSumGroups(const Array::Ptr& groups); static String CalculateCheckSumProperties(const ConfigObject::Ptr& object, const std::set& propertiesBlacklist);