fix: reset rule metrics crashed under certain conditions

This commit is contained in:
Shawn 2022-10-13 16:05:00 +08:00
parent 373bd41170
commit 381c56d52f
1 changed files with 2 additions and 0 deletions

View File

@ -328,6 +328,8 @@ handle_call({create_rule_metrics, Id}, _From,
_ -> RuleSpeeds#{Id => #rule_speed{}} _ -> RuleSpeeds#{Id => #rule_speed{}}
end}}; end}};
handle_call({reset_speeds, _Id}, _From, State = #state{rule_speeds = undefined}) ->
{reply, ok, State};
handle_call({reset_speeds, Id}, _From, State = #state{rule_speeds = RuleSpeedMap}) -> handle_call({reset_speeds, Id}, _From, State = #state{rule_speeds = RuleSpeedMap}) ->
{reply, ok, State#state{rule_speeds = maps:put(Id, #rule_speed{}, RuleSpeedMap)}}; {reply, ok, State#state{rule_speeds = maps:put(Id, #rule_speed{}, RuleSpeedMap)}};