PragmaTwice commented on code in PR #3549:
URL: https://github.com/apache/kvrocks/pull/3549#discussion_r3543762871
##########
src/server/server.cc:
##########
@@ -1548,25 +1548,38 @@ std::string Server::GetInfo(const std::string &ns,
const std::vector<std::string
};
std::string info_str;
+ jsoncons::json json_obj;
bool all = sections.empty() || util::FindICase(sections.begin(),
sections.end(), "all") != sections.end();
bool first = true;
for (const auto &[sec, fn] : info_funcs) {
if (all || util::FindICase(sections.begin(), sections.end(), sec) !=
sections.end()) {
- if (first)
- first = false;
- else
- info_str.append("\r\n");
+ auto entries = fn(this);
+ if (format == InfoFormat::Json) {
+ jsoncons::json sec_obj;
+ for (const auto &entry : entries) {
+ std::visit([&](const auto &v) { sec_obj[entry.name] = v; },
entry.val);
+ }
+ json_obj[sec] = std::move(sec_obj);
+ } else {
+ if (first)
+ first = false;
+ else
+ info_str.append("\r\n");
- info_str.append("# " + sec + "\r\n");
+ info_str.append("# " + sec + "\r\n");
- for (const auto &entry : fn(this)) {
- info_str.append(fmt::format("{}:{}\r\n", entry.name, entry.val));
+ for (const auto &entry : entries) {
+ info_str.append(fmt::format("{}:{}\r\n", entry.name,
entry.ToString()));
Review Comment:
```suggestion
info_str.append(fmt::format("{}:{}\r\n", entry.name,
entry.ValueToString()));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]