Merge pull request #13372 from lafirest/fix/gateway_license
fix: limit gateway connections with license
This commit is contained in:
commit
6c665037de
|
@ -28,7 +28,7 @@
|
||||||
unregister_channel/2
|
unregister_channel/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([lookup_channels/2]).
|
-export([lookup_channels/2, get_connected_client_count/0]).
|
||||||
|
|
||||||
-export([tabname/1]).
|
-export([tabname/1]).
|
||||||
|
|
||||||
|
@ -95,6 +95,24 @@ lookup_channels(Name, ClientId) ->
|
||||||
record(ClientId, ChanPid) ->
|
record(ClientId, ChanPid) ->
|
||||||
#channel{chid = ClientId, pid = ChanPid}.
|
#channel{chid = ClientId, pid = ChanPid}.
|
||||||
|
|
||||||
|
get_connected_client_count() ->
|
||||||
|
Gatewyas = emqx_gateway_utils:find_gateway_definitions(),
|
||||||
|
Fun = fun(#{name := Name}, Acc) ->
|
||||||
|
Tab = tabname(Name),
|
||||||
|
case ets:whereis(Tab) of
|
||||||
|
undefined ->
|
||||||
|
Acc;
|
||||||
|
_ ->
|
||||||
|
case ets:info(Tab, size) of
|
||||||
|
undefined ->
|
||||||
|
Acc;
|
||||||
|
Size ->
|
||||||
|
Acc + Size
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
lists:foldl(Fun, 0, Gatewyas).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
{vsn, "5.1.0"},
|
{vsn, "5.1.0"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_license_sup]},
|
{registered, [emqx_license_sup]},
|
||||||
{applications, [kernel, stdlib, emqx_ctl]},
|
{applications, [kernel, stdlib, emqx_ctl, emqx_gateway]},
|
||||||
{mod, {emqx_license_app, []}}
|
{mod, {emqx_license_app, []}}
|
||||||
]}.
|
]}.
|
||||||
|
|
|
@ -56,7 +56,8 @@ local_connection_count() ->
|
||||||
|
|
||||||
-spec connection_count() -> non_neg_integer().
|
-spec connection_count() -> non_neg_integer().
|
||||||
connection_count() ->
|
connection_count() ->
|
||||||
local_connection_count() + cached_remote_connection_count().
|
local_connection_count() + cached_remote_connection_count() +
|
||||||
|
emqx_gateway_cm_registry:get_connected_client_count().
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed that the license did not count the number of gateway connections
|
Loading…
Reference in New Issue