in prod/native/libcommon/code/ConfigurationManager.cpp [94:141]
void ConfigurationManager::update() {
ConfigurationSnapshot newConfig;
newConfig.revision = getNextRevision();
for (auto const &entry : options_) {
auto optionVal = fetchStringValue(entry.first);
if (!optionVal.has_value()) {
continue; // keep default from snapshot
}
auto &optionValue = optionVal.value();
try {
switch (entry.second.type) {
case OptionMetadata::type::string: {
std::string *value = (std::string *)((std::byte *)&newConfig + entry.second.offset);
value->swap(optionValue);
break;
}
case OptionMetadata::type::boolean: {
bool *value = (bool *)((std::byte *)&newConfig + entry.second.offset);
*value = utils::parseBoolean(optionValue);
break;
}
case OptionMetadata::type::duration: {
auto value = reinterpret_cast<std::chrono::milliseconds *>((std::byte *)&newConfig + entry.second.offset);
*value = utils::convertDurationWithUnit(optionValue);
break;
}
case OptionMetadata::type::loglevel: {
LogLevel *value = (LogLevel *)((std::byte *)&newConfig + entry.second.offset);
*value = utils::parseLogLevel(optionValue);
break;
}
case OptionMetadata::type::bytes: {
std::size_t *value = (std::size_t *)((std::byte *)&newConfig + entry.second.offset);
*value = utils::parseByteUnits(optionValue);
break;
}
}
} catch (std::invalid_argument const &e) {
ELOGF_NF_ERROR(logger_, "ConfigurationManager::update exception: '%s'", e.what());
}
}
//TODO lock
current_ = std::move(newConfig);
}