mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
feat: Add workflow to check config description (#1894)
fixes #1880 --------- Co-authored-by: Sergey Kuznetsov <skuznetsov@ripple.com> Co-authored-by: Alex Kremer <akremer@ripple.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: godexsoft <385326+godexsoft@users.noreply.github.com> Co-authored-by: Shawn Xie <35279399+shawnxie999@users.noreply.github.com>
This commit is contained in:
@@ -274,7 +274,10 @@ static ClioConfigDefinition gClioConfig = ClioConfigDefinition{
|
||||
ConfigValue{ConfigType::Integer}.defaultValue(100'000).withConstraint(gValidateUint32)},
|
||||
{"database.cassandra.threads",
|
||||
ConfigValue{ConfigType::Integer}
|
||||
.defaultValue(static_cast<uint32_t>(std::thread::hardware_concurrency()))
|
||||
.defaultValue(
|
||||
static_cast<uint32_t>(std::thread::hardware_concurrency()),
|
||||
"The number of available CPU cores."
|
||||
)
|
||||
.withConstraint(gValidateUint32)},
|
||||
{"database.cassandra.core_connections_per_host",
|
||||
ConfigValue{ConfigType::Integer}.defaultValue(1).withConstraint(gValidateUint16)},
|
||||
@@ -313,9 +316,9 @@ static ClioConfigDefinition gClioConfig = ClioConfigDefinition{
|
||||
ConfigValue{ConfigType::Double}.defaultValue(1.0).withConstraint(gValidatePositiveDouble)},
|
||||
|
||||
{"workers",
|
||||
ConfigValue{ConfigType::Integer}.defaultValue(std::thread::hardware_concurrency()).withConstraint(gValidateUint32)
|
||||
},
|
||||
|
||||
ConfigValue{ConfigType::Integer}
|
||||
.defaultValue(std::thread::hardware_concurrency(), "The number of available CPU cores.")
|
||||
.withConstraint(gValidateUint32)},
|
||||
{"server.ip", ConfigValue{ConfigType::String}.withConstraint(gValidateIp)},
|
||||
{"server.port", ConfigValue{ConfigType::Integer}.withConstraint(gValidatePort)},
|
||||
{"server.max_queue_size", ConfigValue{ConfigType::Integer}.defaultValue(0).withConstraint(gValidateUint32)},
|
||||
@@ -345,8 +348,10 @@ static ClioConfigDefinition gClioConfig = ClioConfigDefinition{
|
||||
{"cache.page_fetch_size", ConfigValue{ConfigType::Integer}.defaultValue(512).withConstraint(gValidateUint16)},
|
||||
{"cache.load", ConfigValue{ConfigType::String}.defaultValue("async").withConstraint(gValidateLoadMode)},
|
||||
|
||||
{"log_channels.[].channel", Array{ConfigValue{ConfigType::String}.withConstraint(gValidateChannelName)}},
|
||||
{"log_channels.[].log_level", Array{ConfigValue{ConfigType::String}.withConstraint(gValidateLogLevelName)}},
|
||||
{"log_channels.[].channel", Array{ConfigValue{ConfigType::String}.optional().withConstraint(gValidateChannelName)}
|
||||
},
|
||||
{"log_channels.[].log_level",
|
||||
Array{ConfigValue{ConfigType::String}.optional().withConstraint(gValidateLogLevelName)}},
|
||||
|
||||
{"log_level", ConfigValue{ConfigType::String}.defaultValue("info").withConstraint(gValidateLogLevelName)},
|
||||
|
||||
|
||||
@@ -59,13 +59,15 @@ public:
|
||||
* @brief Sets the default value for the config
|
||||
*
|
||||
* @param value The default value
|
||||
* @param description Optional description to use instead of default generated description
|
||||
* @return Reference to this ConfigValue
|
||||
*/
|
||||
[[nodiscard]] ConfigValue&
|
||||
defaultValue(Value value)
|
||||
defaultValue(Value value, std::optional<std::string_view> description = std::nullopt)
|
||||
{
|
||||
auto const err = checkTypeConsistency(type_, value);
|
||||
ASSERT(!err.has_value(), "{}", err->error);
|
||||
description_ = description;
|
||||
value_ = value;
|
||||
return *this;
|
||||
}
|
||||
@@ -213,7 +215,11 @@ public:
|
||||
{
|
||||
stream << "- **Required**: " << (val.isOptional() ? "False" : "True") << "\n";
|
||||
stream << "- **Type**: " << val.type() << "\n";
|
||||
stream << "- **Default value**: " << (val.hasValue() ? *val.value_ : "None") << "\n";
|
||||
if (val.description_.has_value()) {
|
||||
stream << "- **Default value**: " << *val.description_ << "\n";
|
||||
} else {
|
||||
stream << "- **Default value**: " << (val.hasValue() ? *val.value_ : "None") << "\n";
|
||||
}
|
||||
stream << "- **Constraints**: ";
|
||||
|
||||
if (val.getConstraint().has_value()) {
|
||||
@@ -255,6 +261,7 @@ private:
|
||||
bool optional_{false};
|
||||
std::optional<Value> value_;
|
||||
std::optional<std::reference_wrapper<Constraint const>> cons_;
|
||||
std::optional<std::string_view> description_;
|
||||
};
|
||||
|
||||
} // namespace util::config
|
||||
|
||||
Reference in New Issue
Block a user