From d9fc8fbc87575152415406e74c024fa9fae3f96f Mon Sep 17 00:00:00 2001 From: Paulo Zulato Date: Tue, 28 Mar 2023 16:42:05 -0300 Subject: [PATCH] feat: add new command for Elixir expression evaluation Currently, Elixir expressions are evaluated on an EMQX node using the 'eval' command, which works for both Erlang and Elixir expressions. This commit adds the new command 'eval-ex' exclusively for evaluating Elixir expressions on Elixir nodes, similar to 'eval-erl' for Erlang. --- bin/emqx | 25 ++++++++++++++++++++++++- changes/ce/feat-10263.en.md | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 changes/ce/feat-10263.en.md diff --git a/bin/emqx b/bin/emqx index 741aa3718..c0601ec85 100755 --- a/bin/emqx +++ b/bin/emqx @@ -164,6 +164,9 @@ usage() { eval-erl) echo "Evaluate an Erlang expression in the EMQX node, even on Elixir node" ;; + eval-ex) + echo "Evaluate an Elixir expression in the EMQX node. Only applies to Elixir node" + ;; versions) echo "List installed EMQX release versions and their status" ;; @@ -228,7 +231,7 @@ usage() { echo " Install Info: ertspath | root_dir" echo " Runtime Status: pid | ping" echo " Validate Config: check_config" - echo " Advanced: console_clean | escript | rpc | rpcterms | eval | eval-erl" + echo " Advanced: console_clean | escript | rpc | rpcterms | eval | eval-erl | eval-ex" echo '' echo "Execute '$REL_NAME COMMAND help' for more information" ;; @@ -1280,7 +1283,27 @@ case "${COMMAND}" in shift relx_nodetool "eval" "$@" ;; + eval-ex) + assert_node_alive + shift + if [ "$IS_ELIXIR" = "yes" ] + then + "$REL_DIR/elixir" \ + --hidden \ + --name "rand-$(relx_gen_id)-$NAME" \ + --cookie "$COOKIE" \ + --boot "$REL_DIR/start_clean" \ + --boot-var RELEASE_LIB "$ERTS_LIB_DIR" \ + --vm-args "$REL_DIR/remote.vm.args" \ + --erl "-start_epmd false -epmd_module ekka_epmd" \ + --rpc-eval "$NAME" "$@" + else + echo "EMQX node is not an Elixir node" + usage "$COMMAND" + exit 1 + fi + ;; check_config) check_config ;; diff --git a/changes/ce/feat-10263.en.md b/changes/ce/feat-10263.en.md new file mode 100644 index 000000000..e069fc17f --- /dev/null +++ b/changes/ce/feat-10263.en.md @@ -0,0 +1 @@ +Add command 'eval-ex' for Elixir expression evaluation.