refactor(broker): Don't use a macro

This commit is contained in:
k32 2021-12-27 23:03:15 +01:00
parent b5022e5cd6
commit 6ee18b6104
4 changed files with 9 additions and 11 deletions

View File

@ -16,7 +16,7 @@
, {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.0"}}}
, {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.0"}}}
, {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.11.2"}}}
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}}
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.0"}}}
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.22.2"}}}
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}

View File

@ -30,27 +30,25 @@
, rpc_nodes/1
]}).
-define(RPC, gen_rpc).
-define(DefaultClientNum, 1).
call(Node, Mod, Fun, Args) ->
filter_result(?RPC:call(rpc_node(Node), Mod, Fun, Args)).
filter_result(gen_rpc:call(rpc_node(Node), Mod, Fun, Args)).
call(Key, Node, Mod, Fun, Args) ->
filter_result(?RPC:call(rpc_node({Key, Node}), Mod, Fun, Args)).
filter_result(gen_rpc:call(rpc_node({Key, Node}), Mod, Fun, Args)).
multicall(Nodes, Mod, Fun, Args) ->
filter_result(?RPC:multicall(rpc_nodes(Nodes), Mod, Fun, Args)).
filter_result(gen_rpc:multicall(rpc_nodes(Nodes), Mod, Fun, Args)).
multicall(Key, Nodes, Mod, Fun, Args) ->
filter_result(?RPC:multicall(rpc_nodes([{Key, Node} || Node <- Nodes]), Mod, Fun, Args)).
filter_result(gen_rpc:multicall(rpc_nodes([{Key, Node} || Node <- Nodes]), Mod, Fun, Args)).
cast(Node, Mod, Fun, Args) ->
filter_result(?RPC:cast(rpc_node(Node), Mod, Fun, Args)).
filter_result(gen_rpc:cast(rpc_node(Node), Mod, Fun, Args)).
cast(Key, Node, Mod, Fun, Args) ->
filter_result(?RPC:cast(rpc_node({Key, Node}), Mod, Fun, Args)).
filter_result(gen_rpc:cast(rpc_node({Key, Node}), Mod, Fun, Args)).
rpc_node(Node) when is_atom(Node) ->
{Node, rand:uniform(max_client_num())};

View File

@ -54,7 +54,7 @@ defmodule EMQXUmbrella.MixProject do
{:esockd, github: "emqx/esockd", tag: "5.9.0", override: true},
{:mria, github: "emqx/mria", tag: "0.1.5", override: true},
{:ekka, github: "emqx/ekka", tag: "0.11.2", override: true},
{:gen_rpc, github: "emqx/gen_rpc", tag: "2.5.1", override: true},
{:gen_rpc, github: "emqx/gen_rpc", tag: "2.8.0", override: true},
{:minirest, github: "emqx/minirest", tag: "1.2.9", override: true},
{:ecpool, github: "emqx/ecpool", tag: "0.5.2"},
{:replayq, "0.3.3", override: true},

View File

@ -55,7 +55,7 @@
, {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.0"}}}
, {mria, {git, "https://github.com/emqx/mria", {tag, "0.1.5"}}}
, {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.11.2"}}}
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}}
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.0"}}}
, {minirest, {git, "https://github.com/emqx/minirest", {tag, "1.2.9"}}}
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.2"}}}
, {replayq, "0.3.3"}