chore: little change avoid atom leak

This commit is contained in:
William Yang 2023-05-17 11:01:03 +02:00
parent 1c746ed289
commit cdf42760fa
3 changed files with 22 additions and 17 deletions

View File

@ -158,20 +158,18 @@ dispatch(Group, Topic, Delivery = #delivery{message = Msg}, FailedSubs) ->
-spec strategy(emqx_topic:group()) -> strategy().
strategy(Group) ->
case
emqx:get_config(
[
broker,
shared_subscription_group,
%%binary_to_existing_atom(Group, utf8),
binary_to_atom(Group),
strategy
],
undefined
)
of
undefined -> emqx:get_config([broker, shared_subscription_strategy]);
Strategy -> Strategy
try
emqx:get_config([
broker,
shared_subscription_group,
binary_to_existing_atom(Group),
strategy
])
catch
error:{config_not_found, _} ->
get_default_shared_subscription_strategy();
error:badarg ->
get_default_shared_subscription_strategy()
end.
-spec ack_enabled() -> boolean().
@ -555,3 +553,6 @@ delete_route_if_needed({Group, Topic} = GroupTopic) ->
if_no_more_subscribers(GroupTopic, fun() ->
ok = emqx_router:do_delete_route(Topic, {Group, node()})
end).
get_default_shared_subscription_strategy() ->
emqx:get_config([broker, shared_subscription_strategy]).

View File

@ -794,8 +794,8 @@ find_authenticator_config(AuthenticatorID, ConfKeyPath) ->
with_listener(ListenerID, Fun) ->
case find_listener(ListenerID) of
{ok, {BType, BName}} ->
Type = binary_to_existing_atom(BType, utf8),
Name = binary_to_existing_atom(BName, utf8),
Type = binary_to_existing_atom(BType),
Name = binary_to_existing_atom(BName),
ChainName = binary_to_atom(ListenerID),
Fun(Type, Name, ChainName);
{error, Reason} ->

View File

@ -687,11 +687,15 @@ get_metrics_from_local_node(BridgeType, BridgeName) ->
).
is_enabled_bridge(BridgeType, BridgeName) ->
try emqx:get_config([bridges, BridgeType, binary_to_atom(BridgeName)]) of
try emqx:get_config([bridges, BridgeType, binary_to_existing_atom(BridgeName)]) of
ConfMap ->
maps:get(enable, ConfMap, false)
catch
error:{config_not_found, _} ->
throw(not_found);
error:badarg ->
%% catch non-existing atom,
%% none-existing atom means it is not available in config PT storage.
throw(not_found)
end.