chore(exhook): change root name emqx_exhook > exhook
This commit is contained in:
parent
af2868e598
commit
10b110447c
|
@ -2,7 +2,7 @@
|
||||||
## EMQ X Hooks
|
## EMQ X Hooks
|
||||||
##====================================================================
|
##====================================================================
|
||||||
|
|
||||||
emqx_exhook {
|
exhook {
|
||||||
|
|
||||||
servers = [
|
servers = [
|
||||||
##{
|
##{
|
||||||
|
|
|
@ -146,7 +146,7 @@ exhooks(get, _) ->
|
||||||
{200, ServerL2};
|
{200, ServerL2};
|
||||||
|
|
||||||
exhooks(post, #{body := Body}) ->
|
exhooks(post, #{body := Body}) ->
|
||||||
case emqx_exhook_mgr:update_config([emqx_exhook, servers], {add, Body}) of
|
case emqx_exhook_mgr:update_config([exhook, servers], {add, Body}) of
|
||||||
{ok, Result} ->
|
{ok, Result} ->
|
||||||
{201, Result};
|
{201, Result};
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
|
@ -168,7 +168,7 @@ action_with_name(get, #{bindings := #{name := Name}}) ->
|
||||||
end;
|
end;
|
||||||
|
|
||||||
action_with_name(put, #{bindings := #{name := Name}, body := Body}) ->
|
action_with_name(put, #{bindings := #{name := Name}, body := Body}) ->
|
||||||
case emqx_exhook_mgr:update_config([emqx_exhook, servers],
|
case emqx_exhook_mgr:update_config([exhook, servers],
|
||||||
{update, Name, Body}) of
|
{update, Name, Body}) of
|
||||||
{ok, not_found} ->
|
{ok, not_found} ->
|
||||||
{400, #{code => <<"BAD_REQUEST">>,
|
{400, #{code => <<"BAD_REQUEST">>,
|
||||||
|
@ -187,7 +187,7 @@ action_with_name(put, #{bindings := #{name := Name}, body := Body}) ->
|
||||||
end;
|
end;
|
||||||
|
|
||||||
action_with_name(delete, #{bindings := #{name := Name}}) ->
|
action_with_name(delete, #{bindings := #{name := Name}}) ->
|
||||||
case emqx_exhook_mgr:update_config([emqx_exhook, servers],
|
case emqx_exhook_mgr:update_config([exhook, servers],
|
||||||
{delete, Name}) of
|
{delete, Name}) of
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
{200};
|
{200};
|
||||||
|
@ -200,7 +200,7 @@ action_with_name(delete, #{bindings := #{name := Name}}) ->
|
||||||
move(post, #{bindings := #{name := Name}, body := Body}) ->
|
move(post, #{bindings := #{name := Name}, body := Body}) ->
|
||||||
#{<<"position">> := PositionT, <<"related">> := Related} = Body,
|
#{<<"position">> := PositionT, <<"related">> := Related} = Body,
|
||||||
Position = erlang:binary_to_atom(PositionT),
|
Position = erlang:binary_to_atom(PositionT),
|
||||||
case emqx_exhook_mgr:update_config([emqx_exhook, servers],
|
case emqx_exhook_mgr:update_config([exhook, servers],
|
||||||
{move, Name, Position, Related}) of
|
{move, Name, Position, Related}) of
|
||||||
{ok, ok} ->
|
{ok, ok} ->
|
||||||
{200};
|
{200};
|
||||||
|
|
|
@ -108,10 +108,10 @@ lookup(Name) ->
|
||||||
call({lookup, Name}).
|
call({lookup, Name}).
|
||||||
|
|
||||||
enable(Name) ->
|
enable(Name) ->
|
||||||
update_config([emqx_exhook, servers], {enable, Name, true}).
|
update_config([exhook, servers], {enable, Name, true}).
|
||||||
|
|
||||||
disable(Name) ->
|
disable(Name) ->
|
||||||
update_config([emqx_exhook, servers], {enable, Name, false}).
|
update_config([exhook, servers], {enable, Name, false}).
|
||||||
|
|
||||||
server_status(Name) ->
|
server_status(Name) ->
|
||||||
call({server_status, Name}).
|
call({server_status, Name}).
|
||||||
|
@ -176,8 +176,8 @@ post_config_update(_KeyPath, UpdateReq, NewConf, _OldConf, _AppEnvs) ->
|
||||||
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
process_flag(trap_exit, true),
|
process_flag(trap_exit, true),
|
||||||
emqx_conf:add_handler([emqx_exhook, servers], ?MODULE),
|
emqx_conf:add_handler([exhook, servers], ?MODULE),
|
||||||
ServerL = emqx:get_config([emqx_exhook, servers]),
|
ServerL = emqx:get_config([exhook, servers]),
|
||||||
{Waiting, Running, Stopped} = load_all_servers(ServerL),
|
{Waiting, Running, Stopped} = load_all_servers(ServerL),
|
||||||
Orders = reorder(ServerL),
|
Orders = reorder(ServerL),
|
||||||
{ok, ensure_reload_timer(
|
{ok, ensure_reload_timer(
|
||||||
|
|
|
@ -34,11 +34,11 @@
|
||||||
|
|
||||||
-export([namespace/0, roots/0, fields/1, server_config/0]).
|
-export([namespace/0, roots/0, fields/1, server_config/0]).
|
||||||
|
|
||||||
namespace() -> emqx_exhook.
|
namespace() -> exhook.
|
||||||
|
|
||||||
roots() -> [emqx_exhook].
|
roots() -> [exhook].
|
||||||
|
|
||||||
fields(emqx_exhook) ->
|
fields(exhook) ->
|
||||||
[{servers,
|
[{servers,
|
||||||
sc(hoconsc:array(ref(server)),
|
sc(hoconsc:array(ref(server)),
|
||||||
#{default => []})}
|
#{default => []})}
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
-define(CLUSTER_RPC_SHARD, emqx_cluster_rpc_shard).
|
-define(CLUSTER_RPC_SHARD, emqx_cluster_rpc_shard).
|
||||||
|
|
||||||
-define(CONF_DEFAULT, <<"
|
-define(CONF_DEFAULT, <<"
|
||||||
emqx_exhook
|
exhook {
|
||||||
{servers = [
|
servers = [
|
||||||
{ name = default,
|
{ name = default,
|
||||||
url = \"http://127.0.0.1:9000\"
|
url = \"http://127.0.0.1:9000\"
|
||||||
}]
|
}]
|
||||||
|
|
|
@ -27,8 +27,9 @@
|
||||||
-define(CLUSTER_RPC_SHARD, emqx_cluster_rpc_shard).
|
-define(CLUSTER_RPC_SHARD, emqx_cluster_rpc_shard).
|
||||||
|
|
||||||
-define(CONF_DEFAULT, <<"
|
-define(CONF_DEFAULT, <<"
|
||||||
emqx_exhook {servers = [
|
exhook {
|
||||||
{name = default,
|
servers =
|
||||||
|
[ { name = default,
|
||||||
url = \"http://127.0.0.1:9000\"
|
url = \"http://127.0.0.1:9000\"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -49,7 +50,7 @@ init_per_suite(Config) ->
|
||||||
_ = emqx_exhook_demo_svr:start(),
|
_ = emqx_exhook_demo_svr:start(),
|
||||||
ok = emqx_config:init_load(emqx_exhook_schema, ?CONF_DEFAULT),
|
ok = emqx_config:init_load(emqx_exhook_schema, ?CONF_DEFAULT),
|
||||||
emqx_mgmt_api_test_util:init_suite([emqx_exhook]),
|
emqx_mgmt_api_test_util:init_suite([emqx_exhook]),
|
||||||
[Conf] = emqx:get_config([emqx_exhook, servers]),
|
[Conf] = emqx:get_config([exhook, servers]),
|
||||||
[{template, Conf} | Config].
|
[{template, Conf} | Config].
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(Config) ->
|
||||||
|
|
|
@ -31,11 +31,12 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-define(CONF_DEFAULT, <<"
|
-define(CONF_DEFAULT, <<"
|
||||||
emqx_exhook
|
exhook {
|
||||||
{servers = [
|
servers =
|
||||||
{name = default,
|
[ { name = default,
|
||||||
url = \"http://127.0.0.1:9000\"
|
url = \"http://127.0.0.1:9000\"
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
">>).
|
">>).
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ set_special_configs(emqx_dashboard) ->
|
||||||
port => 18083
|
port => 18083
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
emqx_config:put([emqx_dashboard], Config),
|
emqx_config:put([dashboard], Config),
|
||||||
ok;
|
ok;
|
||||||
set_special_configs(_App) ->
|
set_special_configs(_App) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
Loading…
Reference in New Issue