فهرست منبع

fix(iotdb): change `rest` to `restapi`

firest 1 سال پیش
والد
کامیت
636a45ebff

+ 1 - 1
apps/emqx_bridge_iotdb/src/emqx_bridge_iotdb.app.src

@@ -1,7 +1,7 @@
 %% -*- mode: erlang -*-
 {application, emqx_bridge_iotdb, [
     {description, "EMQX Enterprise Apache IoTDB Bridge"},
-    {vsn, "0.2.3"},
+    {vsn, "0.2.4"},
     {modules, [
         emqx_bridge_iotdb,
         emqx_bridge_iotdb_connector

+ 1 - 1
apps/emqx_bridge_iotdb/src/emqx_bridge_iotdb_action_info.erl

@@ -53,7 +53,7 @@ bridge_v1_config_to_action_config(BridgeV1Config, ConnectorName) ->
     ).
 
 bridge_v1_config_to_connector_config(BridgeV1Config) ->
-    ConnectorKeys = schema_keys(emqx_bridge_iotdb_connector, "config_rest"),
+    ConnectorKeys = schema_keys(emqx_bridge_iotdb_connector, "config_restapi"),
     emqx_utils_maps:update_if_present(
         <<"resource_opts">>,
         fun emqx_connector_schema:project_to_connector_resource_opts/1,

+ 15 - 15
apps/emqx_bridge_iotdb/src/emqx_bridge_iotdb_connector.erl

@@ -120,11 +120,11 @@ namespace() -> "iotdb".
 roots() ->
     [].
 
-fields("config_rest") ->
+fields("config_restapi") ->
     proplists_without(
         [url, request, retry_interval, headers],
         emqx_bridge_http_schema:fields("config_connector")
-    ) ++ common_fields(rest) ++
+    ) ++ common_fields(restapi) ++
         fields("connection_fields");
 fields("connection_fields") ->
     [
@@ -206,7 +206,7 @@ common_fields(Driver) ->
                 hoconsc:enum([Driver]),
                 #{
                     desc => ?DESC("config_driver"),
-                    default => <<"rest">>
+                    default => <<"restapi">>
                 }
             )}
     ].
@@ -227,7 +227,7 @@ desc(Struct) when is_list(Struct) ->
 desc(_) ->
     undefined.
 
-connector_config(#{driver := rest} = Conf, #{name := Name, parse_confs := ParseConfs}) ->
+connector_config(#{driver := restapi} = Conf, #{name := Name, parse_confs := ParseConfs}) ->
     #{
         base_url := BaseUrl,
         authentication :=
@@ -266,13 +266,13 @@ resource_type() -> iotdb.
 
 callback_mode() -> async_if_possible.
 
-callback_mode(#{driver := rest}) ->
+callback_mode(#{driver := restapi}) ->
     async_if_possible;
 callback_mode(#{driver := thrift}) ->
     always_sync.
 
 -spec on_start(manager_id(), config()) -> {ok, state()} | no_return().
-on_start(InstanceId, #{driver := rest, iotdb_version := Version} = Config) ->
+on_start(InstanceId, #{driver := restapi, iotdb_version := Version} = Config) ->
     %% [FIXME] The configuration passed in here is pre-processed and transformed
     %% in emqx_bridge_resource:parse_confs/2.
     case emqx_bridge_http_connector:on_start(InstanceId, Config) of
@@ -282,8 +282,8 @@ on_start(InstanceId, #{driver := rest, iotdb_version := Version} = Config) ->
                 instance_id => InstanceId,
                 request => emqx_utils:redact(maps:get(request, State, <<>>))
             }),
-            ?tp(iotdb_bridge_started, #{driver => rest, instance_id => InstanceId}),
-            {ok, State#{driver => rest, iotdb_version => Version, channels => #{}}};
+            ?tp(iotdb_bridge_started, #{driver => restapi, instance_id => InstanceId}),
+            {ok, State#{driver => restapi, iotdb_version => Version, channels => #{}}};
         {error, Reason} ->
             ?SLOG(error, #{
                 msg => "failed_to_start_iotdb_bridge",
@@ -365,7 +365,7 @@ on_start(
     end.
 
 -spec on_stop(manager_id(), state()) -> ok | {error, term()}.
-on_stop(InstanceId, #{driver := rest} = State) ->
+on_stop(InstanceId, #{driver := restapi} = State) ->
     ?SLOG(info, #{
         msg => "stopping_iotdb_bridge",
         connector => InstanceId
@@ -384,7 +384,7 @@ on_stop(InstanceId, #{driver := thrift} = _State) ->
 
 -spec on_get_status(manager_id(), state()) ->
     connected | connecting | {disconnected, state(), term()}.
-on_get_status(InstanceId, #{driver := rest} = State) ->
+on_get_status(InstanceId, #{driver := restapi} = State) ->
     Func = fun(Worker, Timeout) ->
         Request = {?IOTDB_PING_PATH, [], undefined},
         NRequest = emqx_bridge_http_connector:formalize_request(get, Request),
@@ -459,7 +459,7 @@ on_query_async(
     InstanceId,
     {ChannelId, _Message} = Req,
     ReplyFunAndArgs0,
-    #{driver := rest, iotdb_version := IoTDBVsn, channels := Channels} = State
+    #{driver := restapi, iotdb_version := IoTDBVsn, channels := Channels} = State
 ) ->
     ?tp(iotdb_bridge_on_query_async, #{instance_id => InstanceId}),
     ?SLOG(debug, #{
@@ -503,7 +503,7 @@ on_batch_query_async(
     InstId,
     Requests,
     Callback,
-    #{driver := rest, iotdb_version := IoTDBVsn, channels := Channels} = State
+    #{driver := restapi, iotdb_version := IoTDBVsn, channels := Channels} = State
 ) ->
     ?tp(iotdb_bridge_on_batch_query_async, #{instance_id => InstId}),
     [{ChannelId, _Message} | _] = Requests,
@@ -584,7 +584,7 @@ on_format_query_result(Result) ->
 
 on_add_channel(
     InstanceId,
-    #{driver := rest, iotdb_version := Version, channels := Channels} = OldState0,
+    #{driver := restapi, iotdb_version := Version, channels := Channels} = OldState0,
     ChannelId,
     #{
         parameters := #{data := Data} = Parameter
@@ -647,7 +647,7 @@ on_add_channel(
             {ok, OldState#{channels := Channels2}}
     end.
 
-on_remove_channel(InstanceId, #{driver := rest, channels := Channels} = OldState0, ChannelId) ->
+on_remove_channel(InstanceId, #{driver := restapi, channels := Channels} = OldState0, ChannelId) ->
     {ok, OldState} = emqx_bridge_http_connector:on_remove_channel(InstanceId, OldState0, ChannelId),
     Channels2 = maps:remove(ChannelId, Channels),
     {ok, OldState#{channels => Channels2}};
@@ -1075,7 +1075,7 @@ get_data_template(#{data := Data}, _Payloads) when Data =/= [] ->
 get_data_template(#{data := []}, Payloads) ->
     preproc_data_list(Payloads).
 
-do_on_query(InstanceId, ChannelId, Data, #{driver := rest} = State) ->
+do_on_query(InstanceId, ChannelId, Data, #{driver := restapi} = State) ->
     emqx_bridge_http_connector:on_query(InstanceId, {ChannelId, Data}, State);
 do_on_query(InstanceId, _ChannelId, Data, #{driver := thrift} = _State) ->
     ecpool:pick_and_do(InstanceId, {iotdb, insert_tablet, [Data]}, no_handover).

+ 1 - 1
apps/emqx_bridge_iotdb/src/emqx_bridge_iotdb_connector_info.erl

@@ -17,7 +17,7 @@
 ]).
 
 -define(CONNECTOR, emqx_bridge_iotdb_connector).
--define(DRIVER_REST, "rest").
+-define(DRIVER_REST, "restapi").
 -define(DRIVER_THRIFT, "thrift").
 
 type_name() ->

+ 1 - 3
apps/emqx_resource/src/emqx_resource.erl

@@ -496,11 +496,10 @@ list_group_instances(Group) -> emqx_resource_manager:list_group(Group).
 get_callback_mode(Mod) ->
     Mod:callback_mode().
 
-<<<<<<< variant A
 -spec get_resource_type(module()) -> resource_type().
 get_resource_type(Mod) ->
     Mod:resource_type().
->>>>>>> variant B
+
 -spec get_callback_mode(module(), resource_state()) -> callback_mode() | undefined.
 get_callback_mode(Mod, State) ->
     case erlang:function_exported(Mod, callback_mode, 1) of
@@ -509,7 +508,6 @@ get_callback_mode(Mod, State) ->
         _ ->
             undefined
     end.
-======= end
 
 -spec call_start(resource_id(), module(), resource_config()) ->
     {ok, resource_state()} | {error, Reason :: term()}.