Skip to content

Commit

Permalink
Handle stop request with already zero users
Browse files Browse the repository at this point in the history
Handle case where users already reached zero
and there are no users to terminate on stop request
  • Loading branch information
NelsonVides committed Dec 1, 2023
1 parent dc2a825 commit f1f42c8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/amoc_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ handle_start_scenario(_Scenario, _Settings, #state{status = Status} = State) ->
{{error, {invalid_status, Status}}, State}.

-spec handle_stop_scenario(state()) -> {handle_call_res(), state()}.
handle_stop_scenario(#state{scenario = Scenario, scenario_state = ScenarioState,
no_of_users = 0, status = running} = State) ->
amoc_scenario:terminate(Scenario, ScenarioState),
{ok, State#state{status = finished}};
handle_stop_scenario(#state{status = running} = State) ->
terminate_all_users(),
{ok, State#state{status = terminating}};
Expand Down

0 comments on commit f1f42c8

Please sign in to comment.