refactor: rename CRUD functions
This commit is contained in:
parent
ca2d4ad2a0
commit
216a6abed9
|
@ -181,7 +181,7 @@ fields(node_metrics) ->
|
|||
with_link(
|
||||
Name,
|
||||
fun() ->
|
||||
case emqx_cluster_link_config:delete(Name) of
|
||||
case emqx_cluster_link_config:delete_link(Name) of
|
||||
ok ->
|
||||
?NO_CONTENT;
|
||||
{error, Reason} ->
|
||||
|
@ -215,7 +215,7 @@ handle_list() ->
|
|||
?OK(Response).
|
||||
|
||||
handle_create(Name, Params) ->
|
||||
case emqx_cluster_link_config:create(Params) of
|
||||
case emqx_cluster_link_config:create_link(Params) of
|
||||
{ok, Link} ->
|
||||
?CREATED(add_status(Name, Link));
|
||||
{error, Reason} ->
|
||||
|
@ -273,7 +273,7 @@ add_status(Name, Link) ->
|
|||
|
||||
handle_update(Name, Params0) ->
|
||||
Params = Params0#{<<"name">> => Name},
|
||||
case emqx_cluster_link_config:update_one_link(Params) of
|
||||
case emqx_cluster_link_config:update_link(Params) of
|
||||
{ok, Link} ->
|
||||
?OK(add_status(Name, Link));
|
||||
{error, Reason} ->
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
|
||||
-export([
|
||||
%% General
|
||||
create/1,
|
||||
delete/1,
|
||||
update_one_link/1,
|
||||
create_link/1,
|
||||
delete_link/1,
|
||||
update_link/1,
|
||||
update/1,
|
||||
cluster/0,
|
||||
enabled_links/0,
|
||||
|
@ -61,7 +61,7 @@
|
|||
|
||||
%%
|
||||
|
||||
create(LinkConfig) ->
|
||||
create_link(LinkConfig) ->
|
||||
#{<<"name">> := Name} = LinkConfig,
|
||||
case
|
||||
emqx_conf:update(
|
||||
|
@ -77,7 +77,7 @@ create(LinkConfig) ->
|
|||
{error, Reason}
|
||||
end.
|
||||
|
||||
delete(Name) ->
|
||||
delete_link(Name) ->
|
||||
case
|
||||
emqx_conf:update(
|
||||
?LINKS_PATH,
|
||||
|
@ -91,7 +91,7 @@ delete(Name) ->
|
|||
{error, Reason}
|
||||
end.
|
||||
|
||||
update_one_link(LinkConfig) ->
|
||||
update_link(LinkConfig) ->
|
||||
#{<<"name">> := Name} = LinkConfig,
|
||||
case
|
||||
emqx_conf:update(
|
||||
|
@ -294,9 +294,9 @@ remove_link(Name) ->
|
|||
emqx_cluster_link_metrics:drop_metrics(Name).
|
||||
|
||||
update_links(LinksConf) ->
|
||||
[update_link(Link) || Link <- LinksConf].
|
||||
[do_update_link(Link) || Link <- LinksConf].
|
||||
|
||||
update_link({OldLinkConf, #{enable := true, name := Name} = NewLinkConf}) ->
|
||||
do_update_link({OldLinkConf, #{enable := true, name := Name} = NewLinkConf}) ->
|
||||
case what_is_changed(OldLinkConf, NewLinkConf) of
|
||||
both ->
|
||||
_ = ensure_actor_stopped(Name),
|
||||
|
@ -309,7 +309,7 @@ update_link({OldLinkConf, #{enable := true, name := Name} = NewLinkConf}) ->
|
|||
msg_resource ->
|
||||
ok = update_msg_fwd_resource(OldLinkConf, NewLinkConf)
|
||||
end;
|
||||
update_link({_OldLinkConf, #{enable := false, name := Name} = _NewLinkConf}) ->
|
||||
do_update_link({_OldLinkConf, #{enable := false, name := Name} = _NewLinkConf}) ->
|
||||
_ = emqx_cluster_link_mqtt:remove_msg_fwd_resource(Name),
|
||||
ensure_actor_stopped(Name).
|
||||
|
||||
|
|
Loading…
Reference in New Issue