feat(ruleengine): port random && uuid_v4 functions from v4

This commit is contained in:
firest 2023-06-30 11:42:24 +08:00
parent 8b679cf358
commit 872698d19e
4 changed files with 27 additions and 2 deletions

View File

@ -5,7 +5,7 @@
{vsn, "5.0.20"}, {vsn, "5.0.20"},
{modules, []}, {modules, []},
{registered, [emqx_rule_engine_sup, emqx_rule_engine]}, {registered, [emqx_rule_engine_sup, emqx_rule_engine]},
{applications, [kernel, stdlib, rulesql, getopt, emqx_ctl]}, {applications, [kernel, stdlib, rulesql, getopt, emqx_ctl, uuid]},
{mod, {emqx_rule_engine_app, []}}, {mod, {emqx_rule_engine_app, []}},
{env, []}, {env, []},
{licenses, ["Apache-2.0"]}, {licenses, ["Apache-2.0"]},

View File

@ -242,6 +242,13 @@
mongo_date/2 mongo_date/2
]). ]).
%% Random Funcs
-export([
random/0,
uuid_v4/0,
uuid_v4_no_hyphen/0
]).
%% Proc Dict Func %% Proc Dict Func
-export([ -export([
proc_dict_get/1, proc_dict_get/1,
@ -1021,6 +1028,18 @@ term_encode(Term) ->
term_decode(Data) when is_binary(Data) -> term_decode(Data) when is_binary(Data) ->
erlang:binary_to_term(Data). erlang:binary_to_term(Data).
%%------------------------------------------------------------------------------
%% Random Funcs
%%------------------------------------------------------------------------------
random() ->
rand:uniform().
uuid_v4() ->
uuid_str(uuid:get_v4(), binary_standard).
uuid_v4_no_hyphen() ->
uuid_str(uuid:get_v4(), binary_nodash).
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------
%% Dict Funcs %% Dict Funcs
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------
@ -1186,3 +1205,6 @@ convert_timestamp(MillisecondsTimestamp) ->
Secs = MicroTimestamp div 1000_000 - MegaSecs * 1000_000, Secs = MicroTimestamp div 1000_000 - MegaSecs * 1000_000,
MicroSecs = MicroTimestamp rem 1000_000, MicroSecs = MicroTimestamp rem 1000_000,
{MegaSecs, Secs, MicroSecs}. {MegaSecs, Secs, MicroSecs}.
uuid_str(UUID, DisplyOpt) ->
uuid:uuid_to_string(UUID, DisplyOpt).

View File

@ -97,7 +97,9 @@ defmodule EMQXUmbrella.MixProject do
{:gpb, "4.19.7", override: true, runtime: false}, {:gpb, "4.19.7", override: true, runtime: false},
{:hackney, github: "emqx/hackney", tag: "1.18.1-1", override: true}, {:hackney, github: "emqx/hackney", tag: "1.18.1-1", override: true},
# set by hackney (dependency) # set by hackney (dependency)
{:ssl_verify_fun, "1.1.6", override: true} {:ssl_verify_fun, "1.1.6", override: true},
{:uuid, github: "okeuday/uuid", tag: "v2.0.6", override: true},
{:quickrand, github: "okeuday/quickrand", tag: "v2.0.6", override: true}
] ++ ] ++
emqx_apps(profile_info, version) ++ emqx_apps(profile_info, version) ++
enterprise_deps(profile_info) ++ bcrypt_dep() ++ jq_dep() ++ quicer_dep() enterprise_deps(profile_info) ++ bcrypt_dep() ++ jq_dep() ++ quicer_dep()

View File

@ -83,6 +83,7 @@
, {hackney, {git, "https://github.com/emqx/hackney.git", {tag, "1.18.1-1"}}} , {hackney, {git, "https://github.com/emqx/hackney.git", {tag, "1.18.1-1"}}}
%% in conflict by erlavro and rocketmq %% in conflict by erlavro and rocketmq
, {jsone, {git, "https://github.com/emqx/jsone.git", {tag, "1.7.1"}}} , {jsone, {git, "https://github.com/emqx/jsone.git", {tag, "1.7.1"}}}
, {uuid, {git, "https://github.com/okeuday/uuid.git", {tag, "v2.0.6"}}}
]}. ]}.
{xref_ignores, {xref_ignores,