chore: little change avoid atom leak
This commit is contained in:
parent
1c746ed289
commit
cdf42760fa
|
|
@ -158,20 +158,18 @@ dispatch(Group, Topic, Delivery = #delivery{message = Msg}, FailedSubs) ->
|
||||||
|
|
||||||
-spec strategy(emqx_topic:group()) -> strategy().
|
-spec strategy(emqx_topic:group()) -> strategy().
|
||||||
strategy(Group) ->
|
strategy(Group) ->
|
||||||
case
|
try
|
||||||
emqx:get_config(
|
emqx:get_config([
|
||||||
[
|
broker,
|
||||||
broker,
|
shared_subscription_group,
|
||||||
shared_subscription_group,
|
binary_to_existing_atom(Group),
|
||||||
%%binary_to_existing_atom(Group, utf8),
|
strategy
|
||||||
binary_to_atom(Group),
|
])
|
||||||
strategy
|
catch
|
||||||
],
|
error:{config_not_found, _} ->
|
||||||
undefined
|
get_default_shared_subscription_strategy();
|
||||||
)
|
error:badarg ->
|
||||||
of
|
get_default_shared_subscription_strategy()
|
||||||
undefined -> emqx:get_config([broker, shared_subscription_strategy]);
|
|
||||||
Strategy -> Strategy
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec ack_enabled() -> boolean().
|
-spec ack_enabled() -> boolean().
|
||||||
|
|
@ -555,3 +553,6 @@ delete_route_if_needed({Group, Topic} = GroupTopic) ->
|
||||||
if_no_more_subscribers(GroupTopic, fun() ->
|
if_no_more_subscribers(GroupTopic, fun() ->
|
||||||
ok = emqx_router:do_delete_route(Topic, {Group, node()})
|
ok = emqx_router:do_delete_route(Topic, {Group, node()})
|
||||||
end).
|
end).
|
||||||
|
|
||||||
|
get_default_shared_subscription_strategy() ->
|
||||||
|
emqx:get_config([broker, shared_subscription_strategy]).
|
||||||
|
|
|
||||||
|
|
@ -794,8 +794,8 @@ find_authenticator_config(AuthenticatorID, ConfKeyPath) ->
|
||||||
with_listener(ListenerID, Fun) ->
|
with_listener(ListenerID, Fun) ->
|
||||||
case find_listener(ListenerID) of
|
case find_listener(ListenerID) of
|
||||||
{ok, {BType, BName}} ->
|
{ok, {BType, BName}} ->
|
||||||
Type = binary_to_existing_atom(BType, utf8),
|
Type = binary_to_existing_atom(BType),
|
||||||
Name = binary_to_existing_atom(BName, utf8),
|
Name = binary_to_existing_atom(BName),
|
||||||
ChainName = binary_to_atom(ListenerID),
|
ChainName = binary_to_atom(ListenerID),
|
||||||
Fun(Type, Name, ChainName);
|
Fun(Type, Name, ChainName);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
|
|
|
||||||
|
|
@ -687,11 +687,15 @@ get_metrics_from_local_node(BridgeType, BridgeName) ->
|
||||||
).
|
).
|
||||||
|
|
||||||
is_enabled_bridge(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 ->
|
ConfMap ->
|
||||||
maps:get(enable, ConfMap, false)
|
maps:get(enable, ConfMap, false)
|
||||||
catch
|
catch
|
||||||
error:{config_not_found, _} ->
|
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)
|
throw(not_found)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue