Allow immediate processing of just prepared tasks in cron worker runner
Preparing simple worker tasks is super fast, because it just switches the state to null. But the processing of just prepared tasks required the second worker run and also second cron run. This change optimize the behavior and in case there is still time left it immediately starts processing the tasks. [MAILPOET-4684]
This commit is contained in:
committed by
Aschepikov
parent
05b441378d
commit
69ac29d0a7
@@ -47,10 +47,10 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
$this->cronWorkerRunner->run($worker);
|
||||
}
|
||||
|
||||
public function testItPreparesTask() {
|
||||
public function testItPreparesTaskAndProcessesItImmediately() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'prepareTaskStrategy' => Expected::once(true),
|
||||
'processTaskStrategy' => Expected::never(),
|
||||
'processTaskStrategy' => Expected::once(true),
|
||||
]);
|
||||
|
||||
$task = $this->createScheduledTask();
|
||||
@@ -58,7 +58,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
expect($result)->true();
|
||||
$scheduledTask = $this->scheduledTasksRepository->findOneById($task->getId());
|
||||
assert($scheduledTask instanceof ScheduledTaskEntity);
|
||||
expect($scheduledTask->getStatus())->null();
|
||||
expect($scheduledTask->getStatus())->same(ScheduledTaskEntity::STATUS_COMPLETED);
|
||||
}
|
||||
|
||||
public function testItProcessesTask() {
|
||||
|
Reference in New Issue
Block a user