Преглед изворни кода

fix(rules): store rule configs to cluster config files

Shawn пре 3 година
родитељ
комит
93c5fa60b4
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      apps/emqx_rule_engine/src/emqx_rule_engine_api.erl

+ 3 - 3
apps/emqx_rule_engine/src/emqx_rule_engine_api.erl

@@ -207,7 +207,7 @@ param_path_id() ->
                 {ok, _Rule} ->
                 {ok, _Rule} ->
                     {400, #{code => 'BAD_REQUEST', message => <<"rule id already exists">>}};
                     {400, #{code => 'BAD_REQUEST', message => <<"rule id already exists">>}};
                 not_found ->
                 not_found ->
-                    case emqx_conf:update(ConfPath, Params, #{}) of
+                    case emqx_conf:update(ConfPath, Params, #{override_to => cluster}) of
                         {ok, #{post_config_update := #{emqx_rule_engine := AllRules}}} ->
                         {ok, #{post_config_update := #{emqx_rule_engine := AllRules}}} ->
                             [Rule] = get_one_rule(AllRules, Id),
                             [Rule] = get_one_rule(AllRules, Id),
                             {201, format_rule_resp(Rule)};
                             {201, format_rule_resp(Rule)};
@@ -238,7 +238,7 @@ param_path_id() ->
 '/rules/:id'(put, #{bindings := #{id := Id}, body := Params0}) ->
 '/rules/:id'(put, #{bindings := #{id := Id}, body := Params0}) ->
     Params = filter_out_request_body(Params0),
     Params = filter_out_request_body(Params0),
     ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
     ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
-    case emqx_conf:update(ConfPath, Params, #{}) of
+    case emqx_conf:update(ConfPath, Params, #{override_to => cluster}) of
         {ok, #{post_config_update := #{emqx_rule_engine := AllRules}}} ->
         {ok, #{post_config_update := #{emqx_rule_engine := AllRules}}} ->
             [Rule] = get_one_rule(AllRules, Id),
             [Rule] = get_one_rule(AllRules, Id),
             {200, format_rule_resp(Rule)};
             {200, format_rule_resp(Rule)};
@@ -250,7 +250,7 @@ param_path_id() ->
 
 
 '/rules/:id'(delete, #{bindings := #{id := Id}}) ->
 '/rules/:id'(delete, #{bindings := #{id := Id}}) ->
     ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
     ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
-    case emqx_conf:remove(ConfPath, #{}) of
+    case emqx_conf:remove(ConfPath, #{override_to => cluster}) of
         {ok, _} -> {204};
         {ok, _} -> {204};
         {error, Reason} ->
         {error, Reason} ->
             ?SLOG(error, #{msg => "delete_rule_failed",
             ?SLOG(error, #{msg => "delete_rule_failed",