Merge pull request #6954 from mononym/remove_unused_functions_from_resource_and_connector
refactor: remove unused/old functions
This commit is contained in:
commit
c456434e38
|
@ -28,7 +28,6 @@
|
|||
, on_stop/2
|
||||
, on_query/4
|
||||
, on_health_check/2
|
||||
, on_jsonify/1
|
||||
]).
|
||||
|
||||
-export([do_health_check/1]).
|
||||
|
@ -43,9 +42,6 @@ roots() ->
|
|||
%% this schema has no sub-structs
|
||||
fields(_) -> [].
|
||||
|
||||
on_jsonify(Config) ->
|
||||
Config.
|
||||
|
||||
%% ===================================================================
|
||||
on_start(InstId, #{servers := Servers0,
|
||||
port := Port,
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
, on_stop/2
|
||||
, on_query/4
|
||||
, on_health_check/2
|
||||
, on_jsonify/1
|
||||
]).
|
||||
|
||||
%% ecpool callback
|
||||
|
@ -97,9 +96,6 @@ mongo_fields() ->
|
|||
] ++
|
||||
emqx_connector_schema_lib:ssl_fields().
|
||||
|
||||
on_jsonify(Config) ->
|
||||
Config.
|
||||
|
||||
%% ===================================================================
|
||||
|
||||
on_start(InstId, Config = #{mongo_type := Type,
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
, on_stop/2
|
||||
, on_query/4
|
||||
, on_health_check/2
|
||||
, on_jsonify/1
|
||||
]).
|
||||
|
||||
-export([connect/1]).
|
||||
|
@ -43,11 +42,6 @@ fields(config) ->
|
|||
emqx_connector_schema_lib:relational_db_fields() ++
|
||||
emqx_connector_schema_lib:ssl_fields().
|
||||
|
||||
%%=====================================================================
|
||||
|
||||
on_jsonify(#{server := Server}= Config) ->
|
||||
Config#{server => emqx_connector_schema_lib:ip_port_to_string(Server)}.
|
||||
|
||||
%% ===================================================================
|
||||
on_start(InstId, #{server := {Host, Port},
|
||||
database := DB,
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
, on_stop/2
|
||||
, on_query/4
|
||||
, on_health_check/2
|
||||
, on_jsonify/1
|
||||
]).
|
||||
|
||||
-export([connect/1]).
|
||||
|
@ -49,9 +48,6 @@ fields(config) ->
|
|||
emqx_connector_schema_lib:relational_db_fields() ++
|
||||
emqx_connector_schema_lib:ssl_fields().
|
||||
|
||||
on_jsonify(#{server := Server}= Config) ->
|
||||
Config#{server => emqx_connector_schema_lib:ip_port_to_string(Server)}.
|
||||
|
||||
named_queries(type) -> map();
|
||||
named_queries(nullable) -> true;
|
||||
named_queries(_) -> undefined.
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
, on_stop/2
|
||||
, on_query/4
|
||||
, on_health_check/2
|
||||
, on_jsonify/1
|
||||
]).
|
||||
|
||||
-export([do_health_check/1]).
|
||||
|
@ -85,9 +84,6 @@ fields(sentinel) ->
|
|||
redis_fields() ++
|
||||
emqx_connector_schema_lib:ssl_fields().
|
||||
|
||||
on_jsonify(Config) ->
|
||||
Config.
|
||||
|
||||
%% ===================================================================
|
||||
on_start(InstId, #{redis_type := Type,
|
||||
database := Database,
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
-export([ call_start/3 %% start the instance
|
||||
, call_health_check/3 %% verify if the resource is working normally
|
||||
, call_stop/3 %% stop the instance
|
||||
, call_jsonify/2
|
||||
]).
|
||||
|
||||
-export([ list_instances/0 %% list all the instances, id only.
|
||||
|
@ -86,11 +85,8 @@
|
|||
|
||||
-optional_callbacks([ on_query/4
|
||||
, on_health_check/2
|
||||
, on_jsonify/1
|
||||
]).
|
||||
|
||||
-callback on_jsonify(resource_config()) -> jsx:json_term().
|
||||
|
||||
%% when calling emqx_resource:start/1
|
||||
-callback on_start(instance_id(), resource_config()) ->
|
||||
{ok, resource_state()} | {error, Reason :: term()}.
|
||||
|
@ -284,13 +280,6 @@ call_health_check(InstId, Mod, ResourceState) ->
|
|||
call_stop(InstId, Mod, ResourceState) ->
|
||||
?SAFE_CALL(Mod:on_stop(InstId, ResourceState)).
|
||||
|
||||
-spec call_jsonify(module(), resource_config()) -> jsx:json_term().
|
||||
call_jsonify(Mod, Config) ->
|
||||
case erlang:function_exported(Mod, on_jsonify, 1) of
|
||||
false -> Config;
|
||||
true -> ?SAFE_CALL(Mod:on_jsonify(Config))
|
||||
end.
|
||||
|
||||
-spec check_config(resource_type(), raw_resource_config()) ->
|
||||
{ok, resource_config()} | {error, term()}.
|
||||
check_config(ResourceType, Conf) ->
|
||||
|
|
Loading…
Reference in New Issue