Skip to content

Commit

Permalink
Fix errors with concurrency and constant load pool
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanDGiraldoM committed Mar 14, 2024
1 parent 47e8c39 commit 3e204e6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/domain/use_cases/step/step_use_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule DistributedPerformanceAnalyzer.Domain.UseCase.Step.StepUseCase do
[
:poolboy.child_spec(
:worker,
get_pool_config(scenario.name, concurrency),
get_pool_config(scenario.name, step_number, concurrency),
user_config
)
]
Expand All @@ -60,19 +60,21 @@ defmodule DistributedPerformanceAnalyzer.Domain.UseCase.Step.StepUseCase do
%Strategy{initial: initial, increment: increment, constant_load: constant_load},
step_number
) do
if constant_load,
do: initial || increment,
else: initial + increment * (step_number - 1)
if constant_load do
if initial == 0, do: increment, else: initial
else
initial + increment * step_number
end
end

defp get_user_config(%Scenario{} = step) do
{:ok, user} = User.new(step)
user
end

defp get_pool_config(scenario_name, concurrency),
defp get_pool_config(scenario_name, step_number, concurrency),
do: [
name: {:local, String.to_atom("#{scenario_name}_#{concurrency}_worker")},
name: {:local, String.to_atom("#{scenario_name}_#{step_number}_worker")},
worker_module: UserUseCase,
size: concurrency,
max_overflow: 0
Expand Down

0 comments on commit 3e204e6

Please sign in to comment.