Merge pull request #7598 from thalesmg/gen-rpc-oc

feat: use gen_rpc ordered cast for `emqx_rpc:cast/5`
This commit is contained in:
Thales Macedo Garitezi 2022-04-19 09:06:51 -03:00 committed by GitHub
commit f691d9ef9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -47,7 +47,7 @@
]}
).
-define(DefaultClientNum, 1).
-define(DefaultClientNum, 10).
-type badrpc() :: {badrpc, term()} | {badtcp, term()}.
@ -86,11 +86,13 @@ multicall(Key, Nodes, Mod, Fun, Args) ->
-spec cast(node(), module(), atom(), list()) -> cast_result().
cast(Node, Mod, Fun, Args) ->
%% Note: using a non-ordered cast here, since the generated key is
%% random anyway:
gen_rpc:cast(rpc_node(Node), Mod, Fun, Args).
-spec cast(term(), node(), module(), atom(), list()) -> cast_result().
cast(Key, Node, Mod, Fun, Args) ->
gen_rpc:cast(rpc_node({Key, Node}), Mod, Fun, Args).
gen_rpc:ordered_cast(rpc_node({Key, Node}), Mod, Fun, Args).
rpc_node(Node) when is_atom(Node) ->
{Node, rand:uniform(max_client_num())};

View File

@ -780,8 +780,8 @@ rpc {
## @doc rpc.tcp_client_num
## ValueType: Integer
## Range: [1, 256]
## Defaults: 1
tcp_client_num = 1
## Defaults: 10
tcp_client_num = 10
## RCP Client connect timeout.
##

View File

@ -568,7 +568,7 @@ fields("rpc") ->
})}
, {"tcp_client_num",
sc(range(1, 256),
#{ default => 1
#{ default => 10
, desc => "Set the maximum number of RPC communication channels initiated by this node "
"to each remote node."
})}