mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 06:18:07 +01:00
Updated Rector to commit fda8d1af45875248ab46a5a97ad7d207823aaeba
fda8d1af45
[Parallel] Add Option PARALLEL_TIMEOUT_IN_SECONDS and PARALLEL_SYSTEM_ERROR_COUNT_LIMIT constant to allow reconfigure it in rector config (#1673)
This commit is contained in:
parent
a92f92cd40
commit
840ae52412
@ -18,6 +18,8 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PARALLEL, \false);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PARALLEL_MAX_NUMBER_OF_PROCESSES, 16);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PARALLEL_JOB_SIZE, 20);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PARALLEL_TIMEOUT_IN_SECONDS, 120);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PARALLEL_SYSTEM_ERROR_COUNT_LIMIT, 20);
|
||||
// FQN class importing
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \false);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES, \true);
|
||||
|
@ -27,6 +27,7 @@ use RectorPrefix20220114\Symplify\EasyParallel\ValueObject\ParallelProcess;
|
||||
use RectorPrefix20220114\Symplify\EasyParallel\ValueObject\ProcessPool;
|
||||
use RectorPrefix20220114\Symplify\EasyParallel\ValueObject\Schedule;
|
||||
use RectorPrefix20220114\Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use RectorPrefix20220114\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Throwable;
|
||||
/**
|
||||
* Inspired from @see
|
||||
@ -36,14 +37,6 @@ use Throwable;
|
||||
*/
|
||||
final class ParallelFileProcessor
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public const TIMEOUT_IN_SECONDS = 120;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private const SYSTEM_ERROR_COUNT_LIMIT = 20;
|
||||
/**
|
||||
* @var \Symplify\EasyParallel\ValueObject\ProcessPool|null
|
||||
*/
|
||||
@ -53,9 +46,15 @@ final class ParallelFileProcessor
|
||||
* @var \Rector\Parallel\Command\WorkerCommandLineFactory
|
||||
*/
|
||||
private $workerCommandLineFactory;
|
||||
public function __construct(\Rector\Parallel\Command\WorkerCommandLineFactory $workerCommandLineFactory)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
|
||||
*/
|
||||
private $parameterProvider;
|
||||
public function __construct(\Rector\Parallel\Command\WorkerCommandLineFactory $workerCommandLineFactory, \RectorPrefix20220114\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider)
|
||||
{
|
||||
$this->workerCommandLineFactory = $workerCommandLineFactory;
|
||||
$this->parameterProvider = $parameterProvider;
|
||||
}
|
||||
/**
|
||||
* @param Closure(int): void|null $postFileCallback Used for progress bar jump
|
||||
@ -104,6 +103,8 @@ final class ParallelFileProcessor
|
||||
$reachedSystemErrorsCountLimit = \true;
|
||||
$this->processPool->quitAll();
|
||||
};
|
||||
$timeoutInSeconds = $this->parameterProvider->provideIntParameter(\Rector\Core\Configuration\Option::PARALLEL_TIMEOUT_IN_SECONDS);
|
||||
$systemErrorCountLimit = $this->parameterProvider->provideIntParameter(\Rector\Core\Configuration\Option::PARALLEL_SYSTEM_ERROR_COUNT_LIMIT);
|
||||
for ($i = 0; $i < $numberOfProcesses; ++$i) {
|
||||
// nothing else to process, stop now
|
||||
if ($jobs === []) {
|
||||
@ -111,10 +112,10 @@ final class ParallelFileProcessor
|
||||
}
|
||||
$processIdentifier = \RectorPrefix20220114\Nette\Utils\Random::generate();
|
||||
$workerCommandLine = $this->workerCommandLineFactory->create($mainScript, \Rector\Core\Console\Command\ProcessCommand::class, \RectorPrefix20220114\Symplify\PackageBuilder\Console\Command\CommandNaming::classToName(\Rector\Core\Console\Command\WorkerCommand::class), $input, $processIdentifier, $serverPort);
|
||||
$parallelProcess = new \RectorPrefix20220114\Symplify\EasyParallel\ValueObject\ParallelProcess($workerCommandLine, $streamSelectLoop, self::TIMEOUT_IN_SECONDS);
|
||||
$parallelProcess = new \RectorPrefix20220114\Symplify\EasyParallel\ValueObject\ParallelProcess($workerCommandLine, $streamSelectLoop, $timeoutInSeconds);
|
||||
$parallelProcess->start(
|
||||
// 1. callable on data
|
||||
function (array $json) use($parallelProcess, &$systemErrors, &$fileDiffs, &$jobs, $postFileCallback, &$systemErrorsCount, &$reachedInternalErrorsCountLimit, $processIdentifier) : void {
|
||||
function (array $json) use($parallelProcess, &$systemErrors, &$fileDiffs, &$jobs, $postFileCallback, &$systemErrorsCount, &$reachedInternalErrorsCountLimit, $processIdentifier, $systemErrorCountLimit) : void {
|
||||
// decode arrays to objects
|
||||
foreach ($json[\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS] as $jsonError) {
|
||||
if (\is_string($jsonError)) {
|
||||
@ -128,7 +129,7 @@ final class ParallelFileProcessor
|
||||
}
|
||||
$postFileCallback($json[\Rector\Parallel\ValueObject\Bridge::FILES_COUNT]);
|
||||
$systemErrorsCount += $json[\Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS_COUNT];
|
||||
if ($systemErrorsCount >= self::SYSTEM_ERROR_COUNT_LIMIT) {
|
||||
if ($systemErrorsCount >= $systemErrorCountLimit) {
|
||||
$reachedInternalErrorsCountLimit = \true;
|
||||
$this->processPool->quitAll();
|
||||
}
|
||||
@ -157,7 +158,7 @@ final class ParallelFileProcessor
|
||||
}
|
||||
$streamSelectLoop->run();
|
||||
if ($reachedSystemErrorsCountLimit) {
|
||||
$systemErrors[] = new \Rector\Core\ValueObject\Error\SystemError(\sprintf('Reached system errors count limit of %d, exiting...', self::SYSTEM_ERROR_COUNT_LIMIT));
|
||||
$systemErrors[] = new \Rector\Core\ValueObject\Error\SystemError(\sprintf('Reached system errors count limit of %d, exiting...', $systemErrorCountLimit));
|
||||
}
|
||||
return [\Rector\Parallel\ValueObject\Bridge::FILE_DIFFS => $fileDiffs, \Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS => $systemErrors, \Rector\Parallel\ValueObject\Bridge::SYSTEM_ERRORS_COUNT => \count($systemErrors)];
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'c9319540f95a53007d7973111b5cb2f9485c9339';
|
||||
public const PACKAGE_VERSION = 'fda8d1af45875248ab46a5a97ad7d207823aaeba';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-01-14 10:21:45';
|
||||
public const RELEASE_DATE = '2022-01-14 12:36:51';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220114\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
@ -162,4 +162,12 @@ final class Option
|
||||
* @var string
|
||||
*/
|
||||
public const PARALLEL_MAX_NUMBER_OF_PROCESSES = 'parallel-max-number-of-processes';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PARALLEL_TIMEOUT_IN_SECONDS = 'parallel-timeout-in-seconds';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PARALLEL_SYSTEM_ERROR_COUNT_LIMIT = 'parallel-system-error-count-limit';
|
||||
}
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32::getLoader();
|
||||
return ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32
|
||||
class ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite447af771ec96ddcc910f0909a23af32::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,12 +42,12 @@ class ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInite447af771ec96ddcc910f0909a23af32::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequiree447af771ec96ddcc910f0909a23af32($fileIdentifier, $file);
|
||||
composerRequire9ce8117903529ea4d4ec981749d7e257($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -59,7 +59,7 @@ class ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequiree447af771ec96ddcc910f0909a23af32($fileIdentifier, $file)
|
||||
function composerRequire9ce8117903529ea4d4ec981749d7e257($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInite447af771ec96ddcc910f0909a23af32
|
||||
class ComposerStaticInit9ce8117903529ea4d4ec981749d7e257
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -3865,9 +3865,9 @@ class ComposerStaticInite447af771ec96ddcc910f0909a23af32
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite447af771ec96ddcc910f0909a23af32::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite447af771ec96ddcc910f0909a23af32::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite447af771ec96ddcc910f0909a23af32::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
||||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20220114\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32', false) && !interface_exists('ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32', false) && !trait_exists('ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32', false)) {
|
||||
spl_autoload_call('RectorPrefix20220114\ComposerAutoloaderInite447af771ec96ddcc910f0909a23af32');
|
||||
if (!class_exists('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', false) && !interface_exists('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', false) && !trait_exists('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', false)) {
|
||||
spl_autoload_call('RectorPrefix20220114\ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20220114\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -71,9 +71,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220114\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequiree447af771ec96ddcc910f0909a23af32')) {
|
||||
function composerRequiree447af771ec96ddcc910f0909a23af32() {
|
||||
return \RectorPrefix20220114\composerRequiree447af771ec96ddcc910f0909a23af32(...func_get_args());
|
||||
if (!function_exists('composerRequire9ce8117903529ea4d4ec981749d7e257')) {
|
||||
function composerRequire9ce8117903529ea4d4ec981749d7e257() {
|
||||
return \RectorPrefix20220114\composerRequire9ce8117903529ea4d4ec981749d7e257(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user