Pārlūkot izejas kodu

fix(rule): rename enabled to enable

Shawn 4 gadi atpakaļ
vecāks
revīzija
a9c9d9d805

+ 1 - 1
apps/emqx_rule_engine/include/rule_engine.hrl

@@ -47,7 +47,7 @@
         , name := binary()
         , sql := binary()
         , outputs := [output()]
-        , enabled := boolean()
+        , enable := boolean()
         , description => binary()
         , created_at := integer() %% epoch in millisecond precision
         , from := list(topic())

+ 1 - 1
apps/emqx_rule_engine/src/emqx_rule_engine.erl

@@ -223,7 +223,7 @@ do_create_rule(Params = #{id := RuleId, sql := Sql, outputs := Outputs}) ->
                 id => RuleId,
                 name => maps:get(name, Params, <<"">>),
                 created_at => erlang:system_time(millisecond),
-                enabled => maps:get(enabled, Params, true),
+                enable => maps:get(enable, Params, true),
                 sql => Sql,
                 outputs => parse_outputs(Outputs),
                 description => maps:get(description, Params, ""),

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

@@ -197,8 +197,8 @@ param_path_id() ->
             {404, #{code => 'NOT_FOUND', message => <<"Rule Id Not Found">>}}
     end;
 
-'/rules/:id'(put, #{bindings := #{id := Id}, body := Params}) ->
-    Params = filter_out_request_body(Params),
+'/rules/:id'(put, #{bindings := #{id := Id}, body := Params0}) ->
+    Params = filter_out_request_body(Params0),
     ConfPath = emqx_rule_engine:config_key_path() ++ [Id],
     case emqx:update_config(ConfPath, Params, #{}) of
         {ok, #{post_config_update := #{emqx_rule_engine := AllRules}}} ->
@@ -235,7 +235,7 @@ format_rule_resp(#{ id := Id, name := Name,
                     from := Topics,
                     outputs := Output,
                     sql := SQL,
-                    enabled := Enabled,
+                    enable := Enable,
                     description := Descr}) ->
     NodeMetrics = get_rule_metrics(Id),
     #{id => Id,
@@ -245,7 +245,7 @@ format_rule_resp(#{ id := Id, name := Name,
       sql => SQL,
       metrics => aggregate_metrics(NodeMetrics),
       node_metrics => NodeMetrics,
-      enabled => Enabled,
+      enable => Enable,
       created_at => format_datetime(CreatedAt, millisecond),
       description => Descr
      }.

+ 1 - 1
apps/emqx_rule_engine/src/emqx_rule_runtime.erl

@@ -48,7 +48,7 @@
 -spec(apply_rules(list(rule()), input()) -> ok).
 apply_rules([], _Input) ->
     ok;
-apply_rules([#{enabled := false}|More], Input) ->
+apply_rules([#{enable := false}|More], Input) ->
     apply_rules(More, Input);
 apply_rules([Rule = #{id := RuleID}|More], Input) ->
     try apply_rule_discard_result(Rule, Input)

+ 1 - 1
apps/emqx_rule_engine/src/emqx_rule_sqltester.erl

@@ -47,7 +47,7 @@ test_rule(Sql, Select, Context, EventTopics) ->
         sql => Sql,
         from => EventTopics,
         outputs => [#{mod => ?MODULE, func => get_selected_data, args => #{}}],
-        enabled => true,
+        enable => true,
         is_foreach => emqx_rule_sqlparser:select_is_foreach(Select),
         fields => emqx_rule_sqlparser:select_fields(Select),
         doeach => emqx_rule_sqlparser:select_doeach(Select),