Skip to content

Commit

Permalink
rename argument
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 20, 2020
1 parent e807042 commit 9af71de
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions config/horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@
'production' => [
'supervisor-1' => [
'maxProcesses' => 10,
'balanceCooldown' => 1,
'autoScaleMaxShift' => 5,
'balanceCooldown' => 3,
'balanceMaxShift' => 1,
],
],

Expand Down
4 changes: 2 additions & 2 deletions src/AutoScaler.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected function scalePool(Supervisor $supervisor, $pool, $workers)
if ($desiredProcessCount > $totalProcessCount) {
$maxUpShift = min(
$supervisor->options->maxProcesses - $supervisor->totalProcessCount(),
$supervisor->options->autoScaleMaxShift
$supervisor->options->balanceMaxShift
);

$pool->scale(
Expand All @@ -146,7 +146,7 @@ protected function scalePool(Supervisor $supervisor, $pool, $workers)
} elseif ($desiredProcessCount < $totalProcessCount) {
$maxDownShift = min(
$supervisor->totalProcessCount() - $supervisor->options->minProcesses,
$supervisor->options->autoScaleMaxShift
$supervisor->options->balanceMaxShift
);

$pool->scale(
Expand Down
4 changes: 2 additions & 2 deletions src/Console/SupervisorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SupervisorCommand extends Command
{--timeout=60 : The number of seconds a child process can run}
{--tries=0 : Number of times to attempt a job before logging it failed}
{--balance-cooldown=3 : The number of seconds to wait in between auto-scaling attempts}
{--auto-scale-max-shift=1 : The maximum number of processes to increase or decrease per one scaling}';
{--balance-max-shift=1 : The maximum number of processes to increase or decrease per one scaling}';

/**
* The console command description.
Expand Down Expand Up @@ -116,7 +116,7 @@ protected function supervisorOptions()
$this->option('force'),
$this->option('nice'),
$this->option('balance-cooldown'),
$this->option('auto-scale-max-shift')
$this->option('balance-max-shift')
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/SupervisorCommandString.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public static function fromOptions(SupervisorOptions $options)
*/
public static function toOptionsString(SupervisorOptions $options)
{
return sprintf('%s --balance=%s --max-processes=%s --min-processes=%s --nice=%s --balance-cooldown=%s --auto-scale-max-shift=%s',
return sprintf('%s --balance=%s --max-processes=%s --min-processes=%s --nice=%s --balance-cooldown=%s --balance-max-shift=%s',
QueueCommandString::toOptionsString($options), $options->balance,
$options->maxProcesses, $options->minProcesses, $options->nice,
$options->balanceCooldown, $options->autoScaleMaxShift
$options->balanceCooldown, $options->balanceMaxShift
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/SupervisorOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SupervisorOptions extends WorkerOptions
*
* @var int
*/
public $autoScaleMaxShift = 1;
public $balanceMaxShift = 1;

/**
* Create a new worker options instance.
Expand All @@ -93,12 +93,12 @@ class SupervisorOptions extends WorkerOptions
* @param bool $force
* @param int $nice
* @param int $balanceCooldown
* @param int $autoScaleMaxShift
* @param int $balanceMaxShift
*/
public function __construct($name, $connection, $queue = null, $balance = 'off',
$delay = 0, $maxProcesses = 1, $minProcesses = 1, $memory = 128,
$timeout = 60, $sleep = 3, $maxTries = 0, $force = false, $nice = 0,
$balanceCooldown = 3, $autoScaleMaxShift = 1)
$balanceCooldown = 3, $balanceMaxShift = 1)
{
$this->name = $name;
$this->nice = $nice;
Expand All @@ -108,7 +108,7 @@ public function __construct($name, $connection, $queue = null, $balance = 'off',
$this->minProcesses = $minProcesses;
$this->queue = $queue ?: config('queue.connections.'.$connection.'.queue');
$this->balanceCooldown = $balanceCooldown;
$this->autoScaleMaxShift = $autoScaleMaxShift;
$this->balanceMaxShift = $balanceMaxShift;

parent::__construct($delay, $memory, $timeout, $sleep, $maxTries, $force);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function toArray()
'sleep' => $this->sleep,
'timeout' => $this->timeout,
'balanceCooldown' => $this->balanceCooldown,
'autoScaleMaxShift' => $this->autoScaleMaxShift,
'balanceMaxShift' => $this->balanceMaxShift,
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/AddSupervisorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function test_add_supervisor_command_creates_new_supervisor_on_master_pro
$this->assertCount(1, $master->supervisors);

$this->assertEquals(
'exec '.$phpBinary.' artisan horizon:supervisor my-supervisor redis --delay=0 --memory=128 --queue="default" --sleep=3 --timeout=60 --tries=0 --balance=off --max-processes=1 --min-processes=1 --nice=0 --balance-cooldown=3 --auto-scale-max-shift=1',
'exec '.$phpBinary.' artisan horizon:supervisor my-supervisor redis --delay=0 --memory=128 --queue="default" --sleep=3 --timeout=60 --tries=0 --balance=off --max-processes=1 --min-processes=1 --nice=0 --balance-cooldown=3 --balance-max-shift=1',
$master->supervisors->first()->process->getCommandLine()
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/AutoScalerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function test_scaler_considers_max_shift_and_attempts_to_get_closer_to_pr
'second' => ['current' => 75, 'size' => 300, 'runtime' => 75],
]);

$supervisor->options->autoScaleMaxShift = 10;
$supervisor->options->balanceMaxShift = 10;

$scaler->scale($supervisor);

Expand Down

0 comments on commit 9af71de

Please sign in to comment.