mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 03:40:50 +00:00
[DX] Inline PARALLEL_SYSTEM_ERROR_COUNT_LIMIT option to keep user scope outside internal system (#1818)
This commit is contained in:
parent
d670c93519
commit
9fe44263f9
|
@ -22,7 +22,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$parameters->set(Option::PARALLEL_MAX_NUMBER_OF_PROCESSES, 16);
|
||||
$parameters->set(Option::PARALLEL_JOB_SIZE, 20);
|
||||
$parameters->set(Option::PARALLEL_TIMEOUT_IN_SECONDS, 120);
|
||||
$parameters->set(Option::PARALLEL_SYSTEM_ERROR_COUNT_LIMIT, 20);
|
||||
|
||||
// FQN class importing
|
||||
$parameters->set(Option::AUTO_IMPORT_NAMES, false);
|
||||
|
|
|
@ -39,6 +39,11 @@ use Throwable;
|
|||
*/
|
||||
final class ParallelFileProcessor
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private const SYSTEM_ERROR_LIMIT = 50;
|
||||
|
||||
private ProcessPool|null $processPool = null;
|
||||
|
||||
public function __construct(
|
||||
|
@ -125,9 +130,6 @@ final class ParallelFileProcessor
|
|||
};
|
||||
|
||||
$timeoutInSeconds = $this->parameterProvider->provideIntParameter(Option::PARALLEL_TIMEOUT_IN_SECONDS);
|
||||
$systemErrorCountLimit = $this->parameterProvider->provideIntParameter(
|
||||
Option::PARALLEL_SYSTEM_ERROR_COUNT_LIMIT
|
||||
);
|
||||
|
||||
for ($i = 0; $i < $numberOfProcesses; ++$i) {
|
||||
// nothing else to process, stop now
|
||||
|
@ -157,8 +159,7 @@ final class ParallelFileProcessor
|
|||
$postFileCallback,
|
||||
&$systemErrorsCount,
|
||||
&$reachedInternalErrorsCountLimit,
|
||||
$processIdentifier,
|
||||
$systemErrorCountLimit
|
||||
$processIdentifier
|
||||
): void {
|
||||
// decode arrays to objects
|
||||
foreach ($json[Bridge::SYSTEM_ERRORS] as $jsonError) {
|
||||
|
@ -177,7 +178,7 @@ final class ParallelFileProcessor
|
|||
$postFileCallback($json[Bridge::FILES_COUNT]);
|
||||
|
||||
$systemErrorsCount += $json[Bridge::SYSTEM_ERRORS_COUNT];
|
||||
if ($systemErrorsCount >= $systemErrorCountLimit) {
|
||||
if ($systemErrorsCount >= self::SYSTEM_ERROR_LIMIT) {
|
||||
$reachedInternalErrorsCountLimit = true;
|
||||
$this->processPool->quitAll();
|
||||
}
|
||||
|
@ -220,7 +221,7 @@ final class ParallelFileProcessor
|
|||
if ($reachedSystemErrorsCountLimit) {
|
||||
$systemErrors[] = new SystemError(sprintf(
|
||||
'Reached system errors count limit of %d, exiting...',
|
||||
$systemErrorCountLimit
|
||||
self::SYSTEM_ERROR_LIMIT
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -201,11 +201,6 @@ final class Option
|
|||
*/
|
||||
public const PARALLEL_TIMEOUT_IN_SECONDS = 'parallel-timeout-in-seconds';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PARALLEL_SYSTEM_ERROR_COUNT_LIMIT = 'parallel-system-error-count-limit';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user