refactor: Remove unused config-fallback path
This seems to have been here since the dawn of Spark. It is only initialized via the -ConfigFallback option in the sparkd cli, an option that no one ever uses (the cli provides no documentation for it either).
This commit is contained in:
1 parent
1977ad8ad4
commit
64df20cb36
2 files changed
+12
-43
No files matched your search
@@ -50,7 +50,6 @@ namespace internal {
|
||||
const char *MESSAGE_STRING_RULE = "rule";
|
||||
const char *MESSAGE_STRING_VALUE = "value";
|
||||
const char *MESSAGE_STRING_INCLUDE = "include";
|
||||
const char *MESSAGE_STRING_INCLUDE_BACKUP = "fallback";
|
||||
const char *MESSAGE_STRING_MACRO_TYPE = "MacroType";
|
||||
const char *MESSAGE_STRING_MACRO = "macro";
|
||||
|
||||
@@ -75,12 +74,10 @@ std::string get_command_argument(const char *key) {
|
||||
for (; begin != end; begin++) {
|
||||
if (boost::iequals(*begin, key)) {
|
||||
begin++;
|
||||
if (begin == end) {
|
||||
break;
|
||||
} else {
|
||||
os::setenv(CONFIG_SERVER_ENV_VAR, begin->c_str());
|
||||
if (begin != end) {
|
||||
return *begin;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
@@ -361,12 +358,14 @@ void ConfigurationState::initialize_settings() {
|
||||
initialize_defaults(log);
|
||||
|
||||
std::string settings = settings_path();
|
||||
std::string fallback = get_command_argument("-ConfigFallback");
|
||||
bts_assert_msg(!settings.empty(), "Failed to determine config path");
|
||||
os::setenv(CONFIG_SERVER_ENV_VAR, settings.c_str());
|
||||
|
||||
{
|
||||
DEFER( // Do this even if load() fails
|
||||
initialize_builtins(); initialize_macros(); _deferred_queue->process(););
|
||||
load(settings, fallback, log);
|
||||
initialize_builtins(); initialize_macros();
|
||||
_deferred_queue->process(););
|
||||
load(settings, log);
|
||||
}
|
||||
|
||||
std::vector<std::string> descs;
|
||||
@@ -395,29 +394,12 @@ void ConfigurationState::reset() {
|
||||
_port = 80;
|
||||
}
|
||||
|
||||
int ConfigurationState::load(
|
||||
const std::string &url, const std::string &fallback_url, IConfigLog &log) {
|
||||
int ConfigurationState::load(const std::string &url, IConfigLog &log) {
|
||||
std::shared_ptr<proto::Message> new_message(_prototype->New());
|
||||
|
||||
bool loaded = false;
|
||||
try {
|
||||
loaded =
|
||||
load_message(url, *new_message.get(), log, *_deferred_queue.get());
|
||||
} catch (ServerUnreachableException &) {
|
||||
if (fallback_url.empty()) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
loaded = load_message(url, *new_message.get(), log, *_deferred_queue.get());
|
||||
|
||||
if (!loaded && !fallback_url.empty()) {
|
||||
std::string message = "Failed to load: " + url + " using fallback.";
|
||||
log.warning(message);
|
||||
loaded = load_message(
|
||||
fallback_url, *new_message.get(), log, *_deferred_queue.get());
|
||||
if (_host.empty() || _host == "localhost") {
|
||||
tie(_host, _port) = hostname(fallback_url);
|
||||
}
|
||||
}
|
||||
if (_host.empty() || _host == "localhost") {
|
||||
tie(_host, _port) = hostname(url);
|
||||
}
|
||||
@@ -425,14 +407,13 @@ int ConfigurationState::load(
|
||||
return 0;
|
||||
|
||||
std::string include = get_include(*new_message.get());
|
||||
std::string fallback = get_fallback(*new_message.get());
|
||||
|
||||
// insert at front?
|
||||
_config_chain.push_back(new_message);
|
||||
|
||||
// Recursively load includes
|
||||
if (!include.empty()) {
|
||||
return 1 + load(include, fallback, log);
|
||||
return 1 + load(include, log);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -452,13 +433,12 @@ int ConfigurationState::load_string(
|
||||
*_deferred_queue.get());
|
||||
|
||||
std::string include = get_include(*new_message.get());
|
||||
std::string fallback = get_fallback(*new_message.get());
|
||||
|
||||
_config_chain.push_back(new_message);
|
||||
|
||||
int count = 0;
|
||||
if (!include.empty()) {
|
||||
count += load(include, fallback, log);
|
||||
count += load(include, log);
|
||||
}
|
||||
|
||||
if (_host.empty()) {
|
||||
@@ -524,13 +504,6 @@ void ConfigurationState::generate_all_config_proto(
|
||||
include_field->set_type(proto::FieldDescriptorProto_Type_TYPE_STRING);
|
||||
include_field->set_label(proto::FieldDescriptorProto_Label_LABEL_OPTIONAL);
|
||||
|
||||
// Add the 'fallback' field
|
||||
proto::FieldDescriptorProto *backup_field = config_message->add_field();
|
||||
backup_field->set_name(MESSAGE_STRING_INCLUDE_BACKUP);
|
||||
backup_field->set_number(++field_number);
|
||||
backup_field->set_type(proto::FieldDescriptorProto_Type_TYPE_STRING);
|
||||
backup_field->set_label(proto::FieldDescriptorProto_Label_LABEL_OPTIONAL);
|
||||
|
||||
// Add 'macro' message type
|
||||
proto::DescriptorProto *macro_message = bts_config_dp.add_message_type();
|
||||
macro_message->set_name(MESSAGE_STRING_MACRO_TYPE);
|
||||
@@ -963,10 +936,6 @@ std::string get_include(const proto::Message &message) {
|
||||
return get_field(message, MESSAGE_STRING_INCLUDE);
|
||||
}
|
||||
|
||||
std::string get_fallback(const proto::Message &message) {
|
||||
return get_field(message, MESSAGE_STRING_INCLUDE_BACKUP);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace config
|
||||
} // namespace bts
|
||||
Reference in new issue
Block a user