git-hulk commented on code in PR #1855:
URL: https://github.com/apache/kvrocks/pull/1855#discussion_r1374632624
##########
src/config/config.cc:
##########
@@ -359,296 +359,304 @@ void Config::initFieldCallback() {
};
#endif
- std::map<std::string, CallbackFn> callbacks = {
- {"dir",
- [this](Server *srv, const std::string &k, const std::string &v) ->
Status {
- db_dir = dir + "/db";
- {
- std::lock_guard<std::mutex> lg(this->backup_mu);
- if (backup_dir.empty()) {
- backup_dir = dir + "/backup";
- }
- }
- if (log_dir.empty()) log_dir = dir;
- checkpoint_dir = dir + "/checkpoint";
- sync_checkpoint_dir = dir + "/sync_checkpoint";
- backup_sync_dir = dir + "/backup_for_sync";
- return Status::OK();
- }},
- {"backup-dir",
- [this](Server *srv, const std::string &k, const std::string &v) ->
Status {
- std::string previous_backup;
- {
- // Note: currently, backup_mu_ may block by backing up or purging,
- // the command may wait for seconds.
- std::lock_guard<std::mutex> lg(this->backup_mu);
- previous_backup = std::move(backup_dir);
- backup_dir = v;
- }
- if (!previous_backup.empty() && srv != nullptr && !srv->IsLoading()) {
- // LOG(INFO) should be called after log is initialized and server
is loaded.
- LOG(INFO) << "change backup dir from " << previous_backup << " to "
<< v;
- }
- return Status::OK();
- }},
- {"cluster-enabled",
- [this](Server *srv, const std::string &k, const std::string &v) ->
Status {
- if (cluster_enabled) slot_id_encoded = true;
- return Status::OK();
- }},
- {"bind",
- [this](Server *srv, const std::string &k, const std::string &v) ->
Status {
- std::vector<std::string> args = util::Split(v, " \t");
- binds = std::move(args);
- return Status::OK();
- }},
- {"maxclients",
- [](Server *srv, const std::string &k, const std::string &v) -> Status {
- if (!srv) return Status::OK();
- srv->AdjustOpenFilesLimit();
- return Status::OK();
- }},
- {"slaveof",
- [this](Server *srv, const std::string &k, const std::string &v) ->
Status {
- if (v.empty()) {
- return Status::OK();
- }
- std::vector<std::string> args = util::Split(v, " \t");
- if (args.size() != 2) return {Status::NotOK, "wrong number of
arguments"};
- if (args[0] != "no" && args[1] != "one") {
- master_host = args[0];
- auto parse_result = ParseInt<int>(args[1], NumericRange<int>{1,
PORT_LIMIT - 1}, 10);
- if (!parse_result) {
- return {Status::NotOK, "should be between 0 and 65535"};
- }
- master_port = *parse_result;
- }
- return Status::OK();
- }},
- {"profiling-sample-commands",
- [this](Server *srv, const std::string &k, const std::string &v) ->
Status {
- std::vector<std::string> cmds = util::Split(v, ",");
- profiling_sample_all_commands = false;
- profiling_sample_commands.clear();
- for (auto const &cmd : cmds) {
- if (cmd == "*") {
- profiling_sample_all_commands = true;
+ std::map<std::string, CallbackFn> callbacks =
+ {
+ {"workers",
+ [](Server *srv, const std::string &k, const std::string &v) ->
Status {
+ if (!srv) return Status::OK();
+ srv->AdjustWorkerThreads();
+ return Status::OK();
+ }},
Review Comment:
Only those lines are newly added, rest is formatted by clang-format
--
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]