refactoring
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2021 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Job;
|
||||
|
||||
class QueueName
|
||||
{
|
||||
/**
|
||||
* Executes as soon as possible.
|
||||
*/
|
||||
public const Q0 = 'q0';
|
||||
|
||||
/**
|
||||
* Executes every minute.
|
||||
*/
|
||||
public const Q1 = 'q1';
|
||||
|
||||
/**
|
||||
* Executes as soon as possible. For email processing.
|
||||
*/
|
||||
public const E0 = 'e0';
|
||||
}
|
||||
@@ -40,6 +40,7 @@ use Espo\Core\{
|
||||
Notification\NotificatorParams,
|
||||
FieldProcessing\Relation\LinkMultipleSaver,
|
||||
FieldProcessing\SaverParams,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
use DateTime;
|
||||
@@ -657,7 +658,7 @@ class Importer
|
||||
'targetId' => $duplicate->id
|
||||
],
|
||||
'executeAt' => $executeAt,
|
||||
'queue' => 'q1',
|
||||
'queue' => QueueName::Q1,
|
||||
]);
|
||||
|
||||
$this->entityManager->saveEntity($job);
|
||||
|
||||
@@ -44,6 +44,7 @@ use Espo\Core\{
|
||||
Htmlizer\Factory as HtmlizerFactory,
|
||||
Utils\TemplateFileManager,
|
||||
Utils\Log,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
use DateTime;
|
||||
@@ -239,7 +240,7 @@ class Recovery
|
||||
'methodName' => 'removeChangePasswordRequestJob',
|
||||
'data' => ['id' => $passwordChangeRequest->id],
|
||||
'executeTime' => $dt->format('Y-m-d H:i:s'),
|
||||
'queue' => 'q1',
|
||||
'queue' => QueueName::Q1,
|
||||
]);
|
||||
|
||||
$timeDiff = $this->getDelay() - floor((microtime(true) - $microtime) / 1000);
|
||||
|
||||
@@ -35,6 +35,7 @@ use Espo\Core\{
|
||||
Utils\Config,
|
||||
ORM\EntityManager,
|
||||
ApplicationState,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
class AssignmentEmailNotification
|
||||
@@ -129,7 +130,7 @@ class AssignmentEmailNotification
|
||||
'entityType' => $entity->getEntityType(),
|
||||
],
|
||||
'executeTime' => date('Y-m-d H:i:s'),
|
||||
'queue' => 'e0',
|
||||
'queue' => QueueName::E0,
|
||||
]);
|
||||
|
||||
$this->entityManager->saveEntity($job);
|
||||
|
||||
@@ -35,6 +35,7 @@ use Espo\Core\{
|
||||
Utils\Metadata,
|
||||
ORM\EntityManager,
|
||||
ServiceFactory,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
use Espo\Entities\User;
|
||||
@@ -321,7 +322,7 @@ class Stream
|
||||
'entityType' => $entity->getEntityType(),
|
||||
'entityId' => $entity->id
|
||||
],
|
||||
'queue' => 'q1'
|
||||
'queue' => QueueName::Q1,
|
||||
]);
|
||||
|
||||
$this->entityManager->saveEntity($job);
|
||||
@@ -408,7 +409,7 @@ class Stream
|
||||
'entityType' => $entity->getEntityType(),
|
||||
'entityId' => $entity->id
|
||||
],
|
||||
'queue' => 'q1'
|
||||
'queue' => QueueName::Q1,
|
||||
]);
|
||||
|
||||
$this->entityManager->saveEntity($job);
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\{
|
||||
Job\JobManager,
|
||||
Utils\Config,
|
||||
Job\Job,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
class ProcessJobQueueE0 implements Job
|
||||
@@ -51,6 +52,6 @@ class ProcessJobQueueE0 implements Job
|
||||
{
|
||||
$limit = $this->config->get('jobE0MaxPortion', 100);
|
||||
|
||||
$this->jobManager->processQueue('e0', $limit);
|
||||
$this->jobManager->processQueue(QueueName::E0, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\{
|
||||
Job\JobManager,
|
||||
Utils\Config,
|
||||
Job\Job,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
class ProcessJobQueueQ0 implements Job
|
||||
@@ -51,6 +52,6 @@ class ProcessJobQueueQ0 implements Job
|
||||
{
|
||||
$limit = $this->config->get('jobQ0MaxPortion', 200);
|
||||
|
||||
$this->jobManager->processQueue('q0', $limit);
|
||||
$this->jobManager->processQueue(QueueName::Q0, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\{
|
||||
Job\JobManager,
|
||||
Utils\Config,
|
||||
Job\Job,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
class ProcessJobQueueQ1 implements Job
|
||||
@@ -51,6 +52,6 @@ class ProcessJobQueueQ1 implements Job
|
||||
{
|
||||
$limit = $this->config->get('jobQ1MaxPortion', 500);
|
||||
|
||||
$this->jobManager->processQueue('q1', $limit);
|
||||
$this->jobManager->processQueue(QueueName::Q1, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ use Espo\Core\{
|
||||
ORM\Entity,
|
||||
Select\SelectBuilderFactory,
|
||||
Record\ServiceContainer,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
use Espo\{
|
||||
@@ -243,7 +244,7 @@ class Pdf
|
||||
'id' => $attachment->id
|
||||
],
|
||||
'executeTime' => (new DateTime())->modify('+' . $this->removeMassFilePeriod)->format('Y-m-d H:i:s'),
|
||||
'queue' => 'q1',
|
||||
'queue' => QueueName::Q1,
|
||||
]);
|
||||
|
||||
$this->entityManager->saveEntity($job);
|
||||
|
||||
@@ -42,6 +42,7 @@ use Espo\Core\{
|
||||
Utils\DateTime as DateTimeUtil,
|
||||
ServiceFactory,
|
||||
Utils\Log,
|
||||
Job\QueueName,
|
||||
};
|
||||
|
||||
use Espo\{
|
||||
@@ -199,7 +200,7 @@ class LeadCapture
|
||||
'data' => (object) [
|
||||
'id' => $uniqueId->get('name'),
|
||||
],
|
||||
'queue' => 'e0',
|
||||
'queue' => QueueName::E0,
|
||||
]);
|
||||
|
||||
$this->entityManager->saveEntity($job);
|
||||
|
||||
Reference in New Issue
Block a user