fix: reset rule metrics crash if it has not initialized

This commit is contained in:
Shawn 2022-09-29 13:40:01 +08:00
parent a64c0b458f
commit 29c76d16d7
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{}}
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}) ->
{reply, ok, State#state{rule_speeds = maps:put(Id, #rule_speed{}, RuleSpeedMap)}};