Skip to content

Commit

Permalink
Fix creating a interval=0 throttle together with a test
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Nov 26, 2024
1 parent 6ff0b1c commit 2176208
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/throttle/amoc_throttle_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ pool_config(0, _) ->
Config = #{max_n => 0, delay => infinity, status => active, pid => undefined},
maps:from_keys(lists:seq(1, no_of_processes()), Config);
pool_config(Rate, 0) ->
Config = #{max_n => Rate, delay => infinity, status => inactive, pid => undefined},
Config = #{max_n => Rate, delay => 0, status => inactive, pid => undefined},
PoolConfig = #{1 := First} = maps:from_keys(lists:seq(1, no_of_processes()), Config),
PoolConfig#{1 := First#{status => active}};
pool_config(Rate, Interval) ->
Expand Down
4 changes: 3 additions & 1 deletion test/throttle_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ interval_equal_zero_limits_parallelism(_) ->
E1 = #{rate => 36, interval => 0},
?assertMatch({ok, started}, amoc_throttle:start(?FUNCTION_NAME, E1)),
#{pool_config := Config0} = get_throttle_info(?FUNCTION_NAME),
?assertEqual(1, map_size(maps:filter(fun(_, #{status := S}) -> S =:= active end, Config0))).
ActiveWorkers = maps:filter(fun(_, #{status := S}) -> S =:= active end, Config0),
?assertEqual(1, map_size(ActiveWorkers)),
?assertMatch([#{max_n := 36, delay := 0}], maps:values(ActiveWorkers)).

change_rate_to_interval_zero_limits_parallelism(_) ->
?assertMatch({ok, started}, amoc_throttle:start(?FUNCTION_NAME, 100)),
Expand Down

0 comments on commit 2176208

Please sign in to comment.