parent
d86b5ef210
commit
26021b37b3
|
@ -196,4 +196,4 @@ do_unloadall(Scripts) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
do_unload(Script) ->
|
do_unload(Script) ->
|
||||||
emqx_lua_script:unregister_hooks(Script).
|
emqx_lua_script:unregister_hooks(Script), ok.
|
||||||
|
|
|
@ -85,7 +85,7 @@ add_app(AppId, Name) when is_binary(AppId) ->
|
||||||
add_app(AppId, Name, Desc, Status, Expired) when is_binary(AppId) ->
|
add_app(AppId, Name, Desc, Status, Expired) when is_binary(AppId) ->
|
||||||
add_app(AppId, Name, undefined, Desc, Status, Expired).
|
add_app(AppId, Name, undefined, Desc, Status, Expired).
|
||||||
|
|
||||||
-spec(add_app(appid(), binary(), binary(), binary(), boolean(), integer() | undefined)
|
-spec(add_app(appid(), binary(), binary() | undefined, binary(), boolean(), integer() | undefined)
|
||||||
-> {ok, appsecret()}
|
-> {ok, appsecret()}
|
||||||
| {error, term()}).
|
| {error, term()}).
|
||||||
add_app(AppId, Name, Secret, Desc, Status, Expired) when is_binary(AppId) ->
|
add_app(AppId, Name, Secret, Desc, Status, Expired) when is_binary(AppId) ->
|
||||||
|
@ -99,11 +99,11 @@ add_app(AppId, Name, Secret, Desc, Status, Expired) when is_binary(AppId) ->
|
||||||
AddFun = fun() ->
|
AddFun = fun() ->
|
||||||
case mnesia:wread({mqtt_app, AppId}) of
|
case mnesia:wread({mqtt_app, AppId}) of
|
||||||
[] -> mnesia:write(App);
|
[] -> mnesia:write(App);
|
||||||
_ -> mnesia:abort(alread_existed)
|
_ -> mnesia:abort(alread_existed), ok
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case mnesia:transaction(AddFun) of
|
case mnesia:transaction(AddFun) of
|
||||||
{atomic, ok} -> {ok, Secret1};
|
{atomic, _} -> {ok, Secret1};
|
||||||
{aborted, Reason} -> {error, Reason}
|
{aborted, Reason} -> {error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ get_appsecret(AppId) when is_binary(AppId) ->
|
||||||
[] -> undefined
|
[] -> undefined
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec(lookup_app(appid()) -> {{appid(), appsecret(), binary(), binary(), boolean(), integer() | undefined} | undefined}).
|
-spec(lookup_app(appid()) -> undefined | {appid(), appsecret(), binary(), binary(), boolean(), integer() | undefined}).
|
||||||
lookup_app(AppId) when is_binary(AppId) ->
|
lookup_app(AppId) when is_binary(AppId) ->
|
||||||
case mnesia:dirty_read(mqtt_app, AppId) of
|
case mnesia:dirty_read(mqtt_app, AppId) of
|
||||||
[#mqtt_app{id = AppId,
|
[#mqtt_app{id = AppId,
|
||||||
|
|
|
@ -420,7 +420,7 @@ log(["primary-level", Level]) ->
|
||||||
emqx_ctl:print("~s~n", [emqx_logger:get_primary_log_level()]);
|
emqx_ctl:print("~s~n", [emqx_logger:get_primary_log_level()]);
|
||||||
|
|
||||||
log(["handlers", "list"]) ->
|
log(["handlers", "list"]) ->
|
||||||
[emqx_ctl:print("LogHandler(id=~s, level=~s, destination=~s, status=~s)~n", [Id, Level, Dst, Status])
|
_ = [emqx_ctl:print("LogHandler(id=~s, level=~s, destination=~s, status=~s)~n", [Id, Level, Dst, Status])
|
||||||
|| #{id := Id, level := Level, dst := Dst, status := Status} <- emqx_logger:get_log_handlers()],
|
|| #{id := Id, level := Level, dst := Dst, status := Status} <- emqx_logger:get_log_handlers()],
|
||||||
ok;
|
ok;
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ update_resource(#{id := Id, type := Type, config := NewConfig, description := De
|
||||||
{ok, #resource_type{on_create = {Module, Create},
|
{ok, #resource_type{on_create = {Module, Create},
|
||||||
params_spec = ParamSpec}} ->
|
params_spec = ParamSpec}} ->
|
||||||
Config = emqx_rule_validator:validate_params(NewConfig, ParamSpec),
|
Config = emqx_rule_validator:validate_params(NewConfig, ParamSpec),
|
||||||
delete_resource(Id),
|
_ = delete_resource(Id),
|
||||||
emqx_rule_registry:add_resource(#resource{id = Id,
|
emqx_rule_registry:add_resource(#resource{id = Id,
|
||||||
config = Config,
|
config = Config,
|
||||||
type = Type,
|
type = Type,
|
||||||
|
@ -626,4 +626,4 @@ start_reinitial_loop(Id) ->
|
||||||
start_resource(Id);
|
start_resource(Id);
|
||||||
not_found -> ok
|
not_found -> ok
|
||||||
end
|
end
|
||||||
end).
|
end).
|
||||||
|
|
|
@ -326,7 +326,7 @@ update_resource(#{id := Id}, Params) ->
|
||||||
{ok, #resource{id = Id, type = Type} = _OldResource} ->
|
{ok, #resource{id = Id, type = Type} = _OldResource} ->
|
||||||
Config = maps:get(config, parse_resource_params(Params)),
|
Config = maps:get(config, parse_resource_params(Params)),
|
||||||
Description = maps:get(description, parse_resource_params(Params)),
|
Description = maps:get(description, parse_resource_params(Params)),
|
||||||
emqx_rule_engine:update_resource(#{id => Id,
|
_ = emqx_rule_engine:update_resource(#{id => Id,
|
||||||
config => Config,
|
config => Config,
|
||||||
type => Type,
|
type => Type,
|
||||||
description => Description,
|
description => Description,
|
||||||
|
|
Loading…
Reference in New Issue