Commit 6a416746 authored by Ludovic Ganée's avatar Ludovic Ganée

ajout d'une commande ping et d'une fonction clearTube

parent c3695140
Pipeline #7451 passed with stage
in 10 minutes and 50 seconds
......@@ -466,6 +466,34 @@ class Beanstalk
return $this->tube;
}
/**
* Vidange des jobs d'un tube
* @param string|null $tube
* @return Beanstalk
*/
public function clearTube($tube = null)
{
if ($tube && $this->getTube() !== $tube) {
$this->setTube($tube);
}
/** @var Job $job */
while ($this->getPheanstalk()->statsTube($tubeName)->{'current-jobs-buried'}) {
$job = $this->getPheanstalk()->peekBuried($tubeName);
$this->getPheanstalk()->delete($job);
}
while ($this->getPheanstalk()->statsTube($tubeName)->{'current-jobs-delayed'}) {
$job = $this->getPheanstalk()->peekDelayed($tubeName);
$this->getPheanstalk()->delete($job);
}
while ($this->getPheanstalk()->statsTube($tubeName)->{'current-jobs-ready'}) {
$job = $this->getPheanstalk()->peekReady($tubeName);
$this->getPheanstalk()->delete($job);
}
$Jobs = TableRegistry::getTableLocator()->get($this->params['table_jobs']);
$Jobs->deleteAll(['tube' => $this->tube]);
return $this;
}
/**
* Setter de tube
* @param string $tube
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment