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