You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by "empiredan (via GitHub)" <gi...@apache.org> on 2025/04/15 10:27:58 UTC

[PR] feat(make_idempotent): support `get/enable/disable` `atomic_idempotent` on shell [incubator-pegasus]

empiredan opened a new pull request, #2229:
URL: https://github.com/apache/incubator-pegasus/pull/2229

   https://github.com/apache/incubator-pegasus/issues/2197


-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] feat(make_idempotent): support getting/enabling/disabling `atomic_idempotent` on shell [incubator-pegasus]

Posted by "empiredan (via GitHub)" <gi...@apache.org>.
empiredan merged PR #2229:
URL: https://github.com/apache/incubator-pegasus/pull/2229


-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] feat(make_idempotent): support `get/enable/disable` `atomic_idempotent` on shell [incubator-pegasus]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2229:
URL: https://github.com/apache/incubator-pegasus/pull/2229#discussion_r2047150438


##########
src/shell/commands/table_management.cpp:
##########
@@ -1068,3 +1068,100 @@ bool set_max_replica_count(command_executor *e, shell_context *sc, arguments arg
 
     return true;
 }
+
+bool get_atomic_idempotent(command_executor *e, shell_context *sc, arguments args)
+{
+    // get_atomic_idempotent <app_name> [-j|--json]
+
+    // All valid flags are given as follows.
+    static const std::set<std::string> flags = {"j", "json"};
+
+    argh::parser cmd(args.argc, args.argv, argh::parser::PREFER_PARAM_FOR_UNREG_OPTION);
+
+    // Check if the input flags are valid, and there is exact one positional argument
+    // (i.e. app_name).
+    const auto &check = validate_cmd(cmd, {}, flags, 1);
+    if (!check) {
+        SHELL_PRINTLN_ERROR("{}", check.description());
+        return false;
+    }
+
+    // Get the only positional argument as app_name.
+    const std::string app_name(cmd(1).str());
+
+    const bool json = cmd[{"-j", "--json"}];
+
+    const auto &result = sc->ddl_client->get_atomic_idempotent(app_name);
+    auto status = result.get_error();
+    if (status) {
+        status = FMT_ERR(result.get_value().err, result.get_value().hint_message);
+    }
+
+    if (!status) {
+        SHELL_PRINTLN_ERROR("get_atomic_idempotent failed, error={}", status);
+        return true;

Review Comment:
   The error handling in get_atomic_idempotent (and similarly in set_atomic_idempotent) returns true on an error condition, which is inconsistent with patterns (e.g., in create_app) where errors return false; consider standardizing the error return behavior for clarity and consistency.
   ```suggestion
           return false;
   ```



-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] feat(make_idempotent): support `get/enable/disable` `atomic_idempotent` on shell [incubator-pegasus]

Posted by "empiredan (via GitHub)" <gi...@apache.org>.
empiredan commented on code in PR #2229:
URL: https://github.com/apache/incubator-pegasus/pull/2229#discussion_r2048309477


##########
src/shell/commands/table_management.cpp:
##########
@@ -1068,3 +1068,100 @@ bool set_max_replica_count(command_executor *e, shell_context *sc, arguments arg
 
     return true;
 }
+
+bool get_atomic_idempotent(command_executor *e, shell_context *sc, arguments args)
+{
+    // get_atomic_idempotent <app_name> [-j|--json]
+
+    // All valid flags are given as follows.
+    static const std::set<std::string> flags = {"j", "json"};
+
+    argh::parser cmd(args.argc, args.argv, argh::parser::PREFER_PARAM_FOR_UNREG_OPTION);
+
+    // Check if the input flags are valid, and there is exact one positional argument
+    // (i.e. app_name).
+    const auto &check = validate_cmd(cmd, {}, flags, 1);
+    if (!check) {
+        SHELL_PRINTLN_ERROR("{}", check.description());
+        return false;
+    }
+
+    // Get the only positional argument as app_name.
+    const std::string app_name(cmd(1).str());
+
+    const bool json = cmd[{"-j", "--json"}];
+
+    const auto &result = sc->ddl_client->get_atomic_idempotent(app_name);
+    auto status = result.get_error();
+    if (status) {
+        status = FMT_ERR(result.get_value().err, result.get_value().hint_message);
+    }
+
+    if (!status) {
+        SHELL_PRINTLN_ERROR("get_atomic_idempotent failed, error={}", status);
+        return true;

Review Comment:
   Clever ! The return value of shell commands follows the convention that only syntax or usage errors (e.g., invalid arguments) cause a return value of false. Even if an error occurs on the server side during processing, the command will return true. This can be somewhat misleading at first glance.



-- 
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: dev-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org