Skip to content

Commit

Permalink
Reuse plugin filter logic to adapt to emqx rebar3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertwong96 committed May 6, 2019
1 parent b040d37 commit 4e3278a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/emqx_plugins.erl
Expand Up @@ -108,13 +108,20 @@ ensure_file(File) ->

with_loaded_file(File, SuccFun) ->
case read_loaded(File) of
{ok, Names} ->
{ok, Names0} ->
Names = filter_plugins(Names0),
SuccFun(Names);
{error, Error} ->
?LOG(alert, "[Plugins] Failed to read: ~p, error: ~p", [File, Error]),
{error, Error}
end.

filter_plugins(Names) ->
lists:filtermap(fun(Name1) when is_atom(Name1) -> {true, Name1};
({Name1, true}) -> {true, Name1};
({_Name1, false}) -> false
end, Names).

load_plugins(Names, Persistent) ->
Plugins = list(), NotFound = Names -- names(Plugins),
case NotFound of
Expand Down Expand Up @@ -277,10 +284,7 @@ plugin_unloaded(_Name, false) ->
plugin_unloaded(Name, true) ->
case read_loaded() of
{ok, Names0} ->
Names = lists:filtermap(fun(Name1) when is_atom(Name1) -> {true, Name1};
({Name1, true}) -> {true, Name1};
({_Name1, false}) -> false
end, Names0),
Names = filter_plugins(Names0),
case lists:member(Name, Names) of
true ->
write_loaded(lists:delete(Name, Names));
Expand Down

0 comments on commit 4e3278a

Please sign in to comment.