Make rebar3 xref work.
Fixed a bad call in emqx_mod_subscription module also commented out dead code for now in emqx_config.erl
This commit is contained in:
parent
5dfd431040
commit
8a8729f9ea
|
@ -9,6 +9,7 @@ before_install:
|
||||||
script:
|
script:
|
||||||
- make dep-vsn-check
|
- make dep-vsn-check
|
||||||
- make rebar-compile
|
- make rebar-compile
|
||||||
|
- make rebar-xref
|
||||||
- make rebar-eunit
|
- make rebar-eunit
|
||||||
- make rebar-ct
|
- make rebar-ct
|
||||||
- make rebar-cover
|
- make rebar-cover
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -91,6 +91,9 @@ cuttlefish: rebar-deps
|
||||||
mv _build/default/lib/cuttlefish/cuttlefish ./cuttlefish; \
|
mv _build/default/lib/cuttlefish/cuttlefish ./cuttlefish; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rebar-xref:
|
||||||
|
@rebar3 xref
|
||||||
|
|
||||||
rebar-deps:
|
rebar-deps:
|
||||||
@rebar3 get-deps
|
@rebar3 get-deps
|
||||||
|
|
||||||
|
|
|
@ -66,19 +66,19 @@ reload(_App) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-spec(write(atom(), list(env())) -> ok | {error, term()}).
|
-spec(write(atom(), list(env())) -> ok | {error, term()}).
|
||||||
write(App, Terms) ->
|
write(_App, _Terms) -> ok.
|
||||||
Configs = lists:map(fun({Key, Val}) ->
|
% Configs = lists:map(fun({Key, Val}) ->
|
||||||
{cuttlefish_variable:tokenize(binary_to_list(Key)), binary_to_list(Val)}
|
% {cuttlefish_variable:tokenize(binary_to_list(Key)), binary_to_list(Val)}
|
||||||
end, Terms),
|
% end, Terms),
|
||||||
Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]),
|
% Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]),
|
||||||
Schema = cuttlefish_schema:files([Path]),
|
% Schema = cuttlefish_schema:files([Path]),
|
||||||
case cuttlefish_generator:map(Schema, Configs) of
|
% case cuttlefish_generator:map(Schema, Configs) of
|
||||||
[{App, Configs1}] ->
|
% [{App, Configs1}] ->
|
||||||
emqx_cli_config:write_config(App, Configs),
|
% emqx_cli_config:write_config(App, Configs),
|
||||||
lists:foreach(fun({Key, Val}) -> application:set_env(App, Key, Val) end, Configs1);
|
% lists:foreach(fun({Key, Val}) -> application:set_env(App, Key, Val) end, Configs1);
|
||||||
_ ->
|
% _ ->
|
||||||
error
|
% error
|
||||||
end.
|
% end.
|
||||||
|
|
||||||
-spec(dump(atom(), list(env())) -> ok | {error, term()}).
|
-spec(dump(atom(), list(env())) -> ok | {error, term()}).
|
||||||
dump(_App, _Terms) ->
|
dump(_App, _Terms) ->
|
||||||
|
@ -86,47 +86,47 @@ dump(_App, _Terms) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-spec(set(atom(), list(), list()) -> ok).
|
-spec(set(atom(), list(), list()) -> ok).
|
||||||
set(App, Par, Val) ->
|
set(_App, _Par, _Val) -> ok.
|
||||||
emqx_cli_config:run(["config",
|
% emqx_cli_config:run(["config",
|
||||||
"set",
|
% "set",
|
||||||
lists:concat([Par, "=", Val]),
|
% lists:concat([Par, "=", Val]),
|
||||||
lists:concat(["--app=", App])]).
|
% lists:concat(["--app=", App])]).
|
||||||
|
|
||||||
-spec(get(atom(), list()) -> undefined | {ok, term()}).
|
-spec(get(atom(), list()) -> undefined | {ok, term()}).
|
||||||
get(App, Par) ->
|
get(_App, _Par) -> error(no_impl).
|
||||||
case emqx_cli_config:get_cfg(App, Par) of
|
% case emqx_cli_config:get_cfg(App, Par) of
|
||||||
undefined -> undefined;
|
% undefined -> undefined;
|
||||||
Val -> {ok, Val}
|
% Val -> {ok, Val}
|
||||||
end.
|
% end.
|
||||||
|
|
||||||
-spec(get(atom(), list(), atom()) -> term()).
|
-spec(get(atom(), list(), atom()) -> term()).
|
||||||
get(App, Par, Def) ->
|
get(_App, _Par, _Def) -> error(no_impl).
|
||||||
emqx_cli_config:get_cfg(App, Par, Def).
|
% emqx_cli_config:get_cfg(App, Par, Def).
|
||||||
|
|
||||||
|
|
||||||
read_(App) ->
|
read_(_App) -> error(no_impl).
|
||||||
Configs = emqx_cli_config:read_config(App),
|
% Configs = emqx_cli_config:read_config(App),
|
||||||
Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]),
|
% Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]),
|
||||||
case filelib:is_file(Path) of
|
% case filelib:is_file(Path) of
|
||||||
false ->
|
% false ->
|
||||||
[];
|
% [];
|
||||||
true ->
|
% true ->
|
||||||
{_, Mappings, _} = cuttlefish_schema:files([Path]),
|
% {_, Mappings, _} = cuttlefish_schema:files([Path]),
|
||||||
OptionalCfg = lists:foldl(fun(Map, Acc) ->
|
% OptionalCfg = lists:foldl(fun(Map, Acc) ->
|
||||||
Key = cuttlefish_mapping:variable(Map),
|
% Key = cuttlefish_mapping:variable(Map),
|
||||||
case proplists:get_value(Key, Configs) of
|
% case proplists:get_value(Key, Configs) of
|
||||||
undefined ->
|
% undefined ->
|
||||||
[{cuttlefish_variable:format(Key), "", cuttlefish_mapping:doc(Map), false} | Acc];
|
% [{cuttlefish_variable:format(Key), "", cuttlefish_mapping:doc(Map), false} | Acc];
|
||||||
_ -> Acc
|
% _ -> Acc
|
||||||
end
|
% end
|
||||||
end, [], Mappings),
|
% end, [], Mappings),
|
||||||
RequiredCfg = lists:foldl(fun({Key, Val}, Acc) ->
|
% RequiredCfg = lists:foldl(fun({Key, Val}, Acc) ->
|
||||||
case lists:keyfind(Key, 2, Mappings) of
|
% case lists:keyfind(Key, 2, Mappings) of
|
||||||
false -> Acc;
|
% false -> Acc;
|
||||||
Map ->
|
% Map ->
|
||||||
[{cuttlefish_variable:format(Key), Val, cuttlefish_mapping:doc(Map), true} | Acc]
|
% [{cuttlefish_variable:format(Key), Val, cuttlefish_mapping:doc(Map), true} | Acc]
|
||||||
end
|
% end
|
||||||
end, [], Configs),
|
% end, [], Configs),
|
||||||
RequiredCfg ++ OptionalCfg
|
% RequiredCfg ++ OptionalCfg
|
||||||
end.
|
% end.
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ on_session_created(#{client_id := ClientId}, SessAttrs, Topics) ->
|
||||||
emqx_session:subscribe(self(), [{Replace(Topic), #{qos => QoS}} || {Topic, QoS} <- Topics]).
|
emqx_session:subscribe(self(), [{Replace(Topic), #{qos => QoS}} || {Topic, QoS} <- Topics]).
|
||||||
|
|
||||||
unload(_) ->
|
unload(_) ->
|
||||||
emqx_hooks:delete('session.created', fun ?MODULE:on_session_created/3).
|
emqx_hooks:del('session.created', fun ?MODULE:on_session_created/3).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
|
|
Loading…
Reference in New Issue