add IsValidNormalConfig
This commit is contained in:
parent
a6cc881c1c
commit
f7c0890bc8
19
cpp/utils.cc
19
cpp/utils.cc
@ -337,4 +337,23 @@ namespace f8
|
|||||||
return !getenv("SERVER_ENV");
|
return !getenv("SERVER_ENV");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsValidNormalConfig(a8::XObject& conf, std::vector<std::string> fields)
|
||||||
|
{
|
||||||
|
if (conf.GetType() != a8::XOT_ARRAY) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < conf.Size(); ++i) {
|
||||||
|
std::shared_ptr<a8::XObject> node = conf.At(i);
|
||||||
|
if (node->At("instance_id")->AsXValue().GetInt() != i + 1) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
for (std::string& field_name : fields) {
|
||||||
|
if (!node->HasKey(field_name)) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,4 +113,6 @@ namespace f8
|
|||||||
int ExtractChannelIdFromAccountId(const std::string& accountid);
|
int ExtractChannelIdFromAccountId(const std::string& accountid);
|
||||||
|
|
||||||
bool IsOnlineEnv();
|
bool IsOnlineEnv();
|
||||||
|
bool IsValidNormalConfig(a8::XObject& conf, std::vector<std::string> fields);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user