Update fdbcli quota usage output

This commit is contained in:
sfc-gh-tclinkenbeard 2022-06-16 16:26:45 -07:00
parent 99d243197e
commit 308e0113a8
2 changed files with 18 additions and 16 deletions

View File

@ -130,7 +130,14 @@ ACTOR Future<Void> setQuota(Reference<IDatabase> db,
}
}
constexpr auto usage = "Usage: quota [get|set] <tag> [reserved|total] [read|write] <value>\n";
constexpr auto usage =
"quota [get <tag> [reserved|total] [read|write]|set <tag> [reserved|total] [read|write] <value>]";
bool exitFailure() {
fmt::print(usage);
return false;
}
} // namespace
namespace fdb_cli {
@ -138,38 +145,32 @@ namespace fdb_cli {
ACTOR Future<bool> quotaCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens) {
state bool result = true;
if (tokens.size() != 5 && tokens.size() != 6) {
printf(usage);
return false;
return exitFailure();
} else {
auto tag = parseTag(tokens[2]);
auto limitType = parseLimitType(tokens[3]);
auto opType = parseOpType(tokens[4]);
if (!tag.present() || !limitType.present() || !opType.present()) {
printf(usage);
return false;
return exitFailure();
}
if (tokens[1] == "get"_sr) {
if (tokens.size() != 5) {
printf(usage);
return false;
return exitFailure();
}
wait(getQuota(db, tag.get(), limitType.get(), opType.get()));
return true;
} else if (tokens[1] == "set"_sr) {
if (tokens.size() != 6) {
printf(usage);
return false;
return exitFailure();
}
auto const limitValue = parseLimitValue(tokens[5]);
if (!limitValue.present()) {
printf(usage);
return false;
return exitFailure();
}
wait(setQuota(db, tag.get(), limitType.get(), opType.get(), limitValue.get()));
return true;
} else {
printf(usage);
return false;
return exitFailure();
}
}
}

View File

@ -508,9 +508,10 @@ void initHelp() {
CommandHelp("getversion",
"Fetch the current read version",
"Displays the current read version of the database or currently running transaction.");
helpMap["quota"] = CommandHelp("quota",
"quota [get|set] <tag> [reserved|total] [read|write] <value>",
"Get or modify the throughput quota for the specified tag.");
helpMap["quota"] =
CommandHelp("quota",
"quota [get <tag> [reserved|total] [read|write]|set <tag> [reserved|total] [read|write] <value>]",
"Get or modify the throughput quota for the specified tag.");
helpMap["reset"] =
CommandHelp("reset",
"reset the current transaction",