Source of file ProcessQueueTask.php
Size: 1,580 Bytes - Last Modified: 2021-12-23T10:38:27+00:00
/var/www/docs.ssmods.com/process/src/src/Tasks/ProcessQueueTask.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?php namespace StudioBonito\SilverStripe\Queue\Tasks; use StudioBonito\SilverStripe\Queue\Worker; class ProcessQueueTask extends \BuildTask { /** * Task title used in web interface. * * @var string */ protected $title = 'Process task queue'; /** * @var string $description Describe the implications the task has, * and the changes it makes. Accepts HTML formatting. */ protected $description = 'Process the next job on a queue.'; /** * The queue worker instance. * * @var \StudioBonito\SilverStripe\Queue\Worker */ protected $worker; /** * Ensure that the QueueManager instance gets injected. * * @param \StudioBonito\SilverStripe\Queue\Worker $worker */ public function __construct(Worker $worker) { $this->worker = $worker; } /** * Implement this method in the task subclass to * execute via the TaskRunner */ public function run($request) { $connection = $request->getVar('connection'); $queue = $request->getVar('queue'); $delay = $request->getVar('delay') ? : 0; $memory = $request->getVar('memory') ? : 128; $sleep = $request->getVar('sleep') ? : 3; $tries = $request->getVar('tries') ? : 0; $daemon = $request->getVar('daemon'); if ($daemon) { $this->worker->daemon($connection, $queue, $delay, $memory, $sleep, $tries); } else { $this->worker->pop($connection, $queue, $delay, $sleep, $tries); } } } |