MCPcopy Create free account
hub / github.com/apple/foundationdb / throttleHintGenerator

Function throttleHintGenerator

fdbcli/ThrottleCommand.actor.cpp:345–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345std::vector<const char*> throttleHintGenerator(std::vector<StringRef> const& tokens, bool inArgument) {
346 if (tokens.size() == 1) {
347 return { "<on|off|enable auto|disable auto|list>", "[ARGS]" };
348 } else if (tokencmp(tokens[1], "on")) {
349 std::vector<const char*> opts = { "tag", "<TAG>", "[RATE]", "[DURATION]", "[default|immediate|batch]" };
350 if (tokens.size() == 2) {
351 return opts;
352 } else if (((tokens.size() == 3 && inArgument) || tokencmp(tokens[2], "tag")) && tokens.size() < 7) {
353 return std::vector<const char*>(opts.begin() + tokens.size() - 2, opts.end());
354 }
355 } else if (tokencmp(tokens[1], "off")) {
356 if (tokencmp(tokens[tokens.size() - 1], "tag")) {
357 return { "<TAG>" };
358 } else {
359 bool hasType = false;
360 bool hasTag = false;
361 bool hasPriority = false;
362 for (int i = 2; i < tokens.size(); ++i) {
363 if (tokencmp(tokens[i], "all") || tokencmp(tokens[i], "auto") || tokencmp(tokens[i], "manual")) {
364 hasType = true;
365 } else if (tokencmp(tokens[i], "default") || tokencmp(tokens[i], "immediate") ||
366 tokencmp(tokens[i], "batch")) {
367 hasPriority = true;
368 } else if (tokencmp(tokens[i], "tag")) {
369 hasTag = true;
370 ++i;
371 } else {
372 return {};
373 }
374 }
375
376 std::vector<const char*> options;
377 if (!hasType) {
378 options.push_back("[all|auto|manual]");
379 }
380 if (!hasTag) {
381 options.push_back("[tag <TAG>]");
382 }
383 if (!hasPriority) {
384 options.push_back("[default|immediate|batch]");
385 }
386
387 return options;
388 }
389 } else if ((tokencmp(tokens[1], "enable") || tokencmp(tokens[1], "disable")) && tokens.size() == 2) {
390 return { "auto" };
391 } else if (tokens.size() >= 2 && tokencmp(tokens[1], "list")) {
392 if (tokens.size() == 2) {
393 return { "[throttled|recommended|all]", "[LIMITS]" };
394 } else if (tokens.size() == 3 && (tokencmp(tokens[2], "throttled") || tokencmp(tokens[2], "recommended") ||
395 tokencmp(tokens[2], "all"))) {
396 return { "[LIMITS]" };
397 }
398 } else if (tokens.size() == 2 && inArgument) {
399 return { "[ARGS]" };
400 }
401
402 return std::vector<const char*>();

Callers

nothing calls this directly

Calls 5

tokencmpFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected