Skip to content
Snippets Groups Projects
Commit 8bef458a authored by Julien LE GALL's avatar Julien LE GALL
Browse files

Suppression systématique du job dès qu'il est réservé

parent f6e65524
No related branches found
No related tags found
No related merge requests found
......@@ -4,13 +4,8 @@ declare(strict_types=1);
namespace S2lowLegacy\Class;
use Pheanstalk\Exception\CommandException;
use Pheanstalk\Exception\ServerException;
use Pheanstalk\Job;
use Pheanstalk\Pheanstalk;
use Pheanstalk\PheanstalkInterface;
use S2lowLegacy\Lib\SigTermHandler;
use Throwable;
/**
* WorkerRunner qui va
......@@ -35,11 +30,13 @@ class WorkerRunnerWithSelfUpdatedBeanstalkd implements IWorkerRunnerStrategies
public function getAllId(IWorker $worker, S2lowLogger $s2lowLogger): iterable
{
while (true) {
$job = $this->queue->reserve(1);
$job = $this->queue->reserve(0);
if (!$job) {
return false;
}
yield $job->getData();
$data = $job->getData();
$this->queue->delete($job);
yield $data;
}
}
......
......@@ -77,6 +77,10 @@ class WorkerRunnerWithSelfUpdatedBeanstalkdTest extends TestCase
$this->queue->method('reserve')->willReturnOnConsecutiveCalls($this->Job, false);
$this->Job->expects(static::once())->method('getData')->willReturn('data');
// Le job est supprimé systématiquement avant même d'être traité
// Autrement, la queue risque d'être bloquée
$this->queue->expects(self::once())->method('delete')->with($this->Job);
// Le heliosReceptionWorker est capable de traiter
$this->heliosReceptionWorker->expects(static::once())
->method('getData')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment