git-hulk commented on code in PR #3560:
URL: https://github.com/apache/kvrocks/pull/3560#discussion_r3607359658


##########
src/config/config.cc:
##########
@@ -444,6 +446,47 @@ void Config::initFieldValidator() {
 // The callback function would be invoked after the field was set,
 // it may change related fields or re-format the field. for example,
 // when the 'dir' was set, the db-dir or backup-dir should be reset as well.
+// Parses a client-output-buffer-limit spec like "normal 0 0 0 pubsub 32m 8m 
60"
+// and applies it to the limits of the specified client kinds. The full spec is
+// parsed before applying anything, so a malformed quadruple cannot leave the
+// limits partially updated.
+Status Config::parseClientOutputBufferLimits(const std::string &v) {
+  std::vector<std::string> args = util::Split(v, " \t");
+  if (args.empty() || args.size() % 4 != 0) {
+    return {Status::NotOK, "should be in the format of <class> <hard limit> 
<soft limit> <soft seconds> ..."};
+  }
+
+  struct ParsedLimit {
+    ClientKind kind;
+    uint64_t hard_limit_bytes, soft_limit_bytes, soft_limit_seconds;
+  };
+  std::vector<ParsedLimit> parsed;
+  for (size_t i = 0; i < args.size(); i += 4) {
+    ClientKind kind = ClientKind::kNormal;
+    if (util::EqualICase(args[i], "normal")) {
+      kind = ClientKind::kNormal;
+    } else if (util::EqualICase(args[i], "slave") || util::EqualICase(args[i], 
"replica")) {
+      kind = ClientKind::kSlave;
+    } else if (util::EqualICase(args[i], "pubsub")) {
+      kind = ClientKind::kPubsub;
+    } else {
+      return {Status::NotOK, fmt::format("unknown client kind '{}'", args[i])};
+    }
+    auto hard = GET_OR_RET(ParseSizeAndUnit(args[i + 1]).Prefixed("invalid 
hard limit"));

Review Comment:
   Yes, but we don't handle this in this PR.



-- 
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]

Reply via email to