fix(emqx_bridge): add import_config/1 cb to emqx_bridge_v2
This commit is contained in:
parent
d94193ac15
commit
bc8c291820
|
@ -62,7 +62,9 @@
|
|||
|
||||
%% Data backup
|
||||
-export([
|
||||
import_config/1
|
||||
import_config/1,
|
||||
%% exported for emqx_bridge_v2
|
||||
import_config/4
|
||||
]).
|
||||
|
||||
-export([query_opts/1]).
|
||||
|
@ -442,15 +444,18 @@ do_check_deps_and_remove(BridgeType, BridgeName, RemoveDeps) ->
|
|||
%%----------------------------------------------------------------------------------------
|
||||
|
||||
import_config(RawConf) ->
|
||||
RootKeyPath = config_key_path(),
|
||||
BridgesConf = maps:get(<<"bridges">>, RawConf, #{}),
|
||||
import_config(RawConf, <<"bridges">>, ?ROOT_KEY, config_key_path()).
|
||||
|
||||
%% Used in emqx_bridge_v2
|
||||
import_config(RawConf, RawConfKey, RootKey, RootKeyPath) ->
|
||||
BridgesConf = maps:get(RawConfKey, RawConf, #{}),
|
||||
OldBridgesConf = emqx:get_raw_config(RootKeyPath, #{}),
|
||||
MergedConf = merge_confs(OldBridgesConf, BridgesConf),
|
||||
case emqx_conf:update(RootKeyPath, MergedConf, #{override_to => cluster}) of
|
||||
{ok, #{raw_config := NewRawConf}} ->
|
||||
{ok, #{root_key => ?ROOT_KEY, changed => changed_paths(OldBridgesConf, NewRawConf)}};
|
||||
{ok, #{root_key => RootKey, changed => changed_paths(OldBridgesConf, NewRawConf)}};
|
||||
Error ->
|
||||
{error, #{root_key => ?ROOT_KEY, reason => Error}}
|
||||
{error, #{root_key => RootKey, reason => Error}}
|
||||
end.
|
||||
|
||||
merge_confs(OldConf, NewConf) ->
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
-module(emqx_bridge_v2).
|
||||
|
||||
-behaviour(emqx_config_handler).
|
||||
% -behaviour(emqx_config_backup).
|
||||
-behaviour(emqx_config_backup).
|
||||
|
||||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
|
@ -77,6 +77,11 @@
|
|||
pre_config_update/3
|
||||
]).
|
||||
|
||||
%% Data backup
|
||||
-export([
|
||||
import_config/1
|
||||
]).
|
||||
|
||||
%% Compatibility API
|
||||
|
||||
-export([
|
||||
|
@ -731,6 +736,14 @@ bridge_v2_type_to_connector_type(kafka_producer) ->
|
|||
bridge_v2_type_to_connector_type(azure_event_hub) ->
|
||||
azure_event_hub.
|
||||
|
||||
%%====================================================================
|
||||
%% Data backup API
|
||||
%%====================================================================
|
||||
|
||||
import_config(RawConf) ->
|
||||
%% bridges v2 structure
|
||||
emqx_bridge:import_config(RawConf, <<"bridges_v2">>, ?ROOT_KEY, config_key_path()).
|
||||
|
||||
%%====================================================================
|
||||
%% Config Update Handler API
|
||||
%%====================================================================
|
||||
|
|
Loading…
Reference in New Issue