Selaa lähdekoodia

refactor: rename emqx_api_lib to emqx_utils_api

Stefan Strigler 2 vuotta sitten
vanhempi
commit
d0df086c80

+ 1 - 1
apps/emqx_bridge/src/emqx_bridge_api.erl

@@ -20,7 +20,7 @@
 -include_lib("typerefl/include/types.hrl").
 -include_lib("hocon/include/hoconsc.hrl").
 -include_lib("emqx/include/logger.hrl").
--include_lib("emqx/include/emqx_api_lib.hrl").
+-include_lib("emqx_utils/include/emqx_utils_api.hrl").
 -include_lib("emqx_bridge/include/emqx_bridge.hrl").
 
 -import(hoconsc, [mk/2, array/1, enum/1]).

+ 3 - 3
apps/emqx_dashboard/src/emqx_dashboard_monitor_api.erl

@@ -122,7 +122,7 @@ fields(sampler_current) ->
 monitor(get, #{query_string := QS, bindings := Bindings}) ->
     Latest = maps:get(<<"latest">>, QS, infinity),
     RawNode = maps:get(node, Bindings, <<"all">>),
-    emqx_api_lib:with_node_or_cluster(RawNode, dashboard_samplers_fun(Latest)).
+    emqx_utils_api:with_node_or_cluster(RawNode, dashboard_samplers_fun(Latest)).
 
 dashboard_samplers_fun(Latest) ->
     fun(NodeOrCluster) ->
@@ -133,10 +133,10 @@ dashboard_samplers_fun(Latest) ->
     end.
 
 monitor_current(get, #{bindings := []}) ->
-    emqx_api_lib:with_node_or_cluster(erlang:node(), fun emqx_dashboard_monitor:current_rate/1);
+    emqx_utils_api:with_node_or_cluster(erlang:node(), fun emqx_dashboard_monitor:current_rate/1);
 monitor_current(get, #{bindings := Bindings}) ->
     RawNode = maps:get(node, Bindings, <<"all">>),
-    emqx_api_lib:with_node_or_cluster(RawNode, fun current_rate/1).
+    emqx_utils_api:with_node_or_cluster(RawNode, fun current_rate/1).
 
 current_rate(Node) ->
     case emqx_dashboard_monitor:current_rate(Node) of

+ 3 - 3
apps/emqx_management/src/emqx_mgmt_api_nodes.erl

@@ -247,13 +247,13 @@ nodes(get, _Params) ->
     list_nodes(#{}).
 
 node(get, #{bindings := #{node := NodeName}}) ->
-    emqx_api_lib:with_node(NodeName, to_ok_result_fun(fun get_node/1)).
+    emqx_utils_api:with_node(NodeName, to_ok_result_fun(fun get_node/1)).
 
 node_metrics(get, #{bindings := #{node := NodeName}}) ->
-    emqx_api_lib:with_node(NodeName, to_ok_result_fun(fun emqx_mgmt:get_metrics/1)).
+    emqx_utils_api:with_node(NodeName, to_ok_result_fun(fun emqx_mgmt:get_metrics/1)).
 
 node_stats(get, #{bindings := #{node := NodeName}}) ->
-    emqx_api_lib:with_node(NodeName, to_ok_result_fun(fun emqx_mgmt:get_stats/1)).
+    emqx_utils_api:with_node(NodeName, to_ok_result_fun(fun emqx_mgmt:get_stats/1)).
 
 %%--------------------------------------------------------------------
 %% api apply

apps/emqx/include/emqx_api_lib.hrl → apps/emqx_utils/include/emqx_utils_api.hrl


+ 1 - 0
apps/emqx_utils/src/emqx_utils.app.src

@@ -5,6 +5,7 @@
     {vsn, "5.0.0"},
     {modules, [
         emqx_utils,
+        emqx_utils_api,
         emqx_utils_binary,
         emqx_utils_ets,
         emqx_utils_json,

+ 2 - 2
apps/emqx/src/emqx_api_lib.erl

@@ -14,14 +14,14 @@
 %% limitations under the License.
 %%--------------------------------------------------------------------
 
--module(emqx_api_lib).
+-module(emqx_utils_api).
 
 -export([
     with_node/2,
     with_node_or_cluster/2
 ]).
 
--include("emqx_api_lib.hrl").
+-include("emqx_utils_api.hrl").
 
 -define(NODE_NOT_FOUND(NODE), ?NOT_FOUND(<<"Node not found: ", NODE/binary>>)).
 

+ 5 - 5
apps/emqx/test/emqx_api_lib_SUITE.erl

@@ -14,12 +14,12 @@
 %% limitations under the License.
 %%--------------------------------------------------------------------
 
--module(emqx_api_lib_SUITE).
+-module(emqx_utils_api_SUITE).
 
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_api_lib.hrl").
+-include("emqx_utils_api.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 -define(DUMMY, dummy_module).
@@ -45,14 +45,14 @@ end_per_testcase(_Case, _Config) ->
     meck:unload(?DUMMY).
 
 t_with_node(_) ->
-    test_with(fun emqx_api_lib:with_node/2, [<<"all">>]).
+    test_with(fun emqx_utils_api:with_node/2, [<<"all">>]).
 
 t_with_node_or_cluster(_) ->
-    test_with(fun emqx_api_lib:with_node_or_cluster/2, []),
+    test_with(fun emqx_utils_api:with_node_or_cluster/2, []),
     meck:reset(?DUMMY),
     ?assertEqual(
         ?OK(success),
-        emqx_api_lib:with_node_or_cluster(
+        emqx_utils_api:with_node_or_cluster(
             <<"all">>,
             fun ?DUMMY:expect_success/1
         )

+ 1 - 1
lib-ee/emqx_ee_schema_registry/src/emqx_ee_schema_registry_http_api.erl

@@ -8,7 +8,7 @@
 -include("emqx_ee_schema_registry.hrl").
 -include_lib("hocon/include/hoconsc.hrl").
 -include_lib("emqx/include/logger.hrl").
--include_lib("emqx/include/emqx_api_lib.hrl").
+-include_lib("emqx_utils/include/emqx_utils_api.hrl").
 
 -export([
     namespace/0,