[DX] Inline PARALLEL_SYSTEM_ERROR_COUNT_LIMIT option to keep user scope outside internal system (#1818)

This commit is contained in:
Tomas Votruba 2022-02-15 21:58:51 +00:00 committed by GitHub
parent d670c93519
commit 9fe44263f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 13 deletions

View File

@ -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);

View File

@ -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
));
}

View File

@ -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
*/