Source of file JobWorker.php
Size: 1,386 Bytes - Last Modified: 2021-12-23T10:33:37+00:00
/var/www/docs.ssmods.com/process/src/src/Workers/JobWorker.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | <?php /** * @author marcus@symbiote.com.au * @license BSD License http://silverstripe.org/bsd-license/ */ namespace Symbiote\QueuedJobs\Workers; use SilverStripe\ORM\DataList; use SilverStripe\ORM\FieldType\DBDatetime; use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor; use Symbiote\QueuedJobs\Services\QueuedJobService; // GearmanHandler is an extension that could be not available. /** * @todo Test and implement against it for SilverStripe 4.x compatibility */ if (interface_exists('GearmanHandler')) { class JobWorker implements \GearmanHandler { /** * @var QueuedJobService */ public $queuedJobService; /** * @return string */ public function getName() { return 'jobqueueExecute'; } /** * @param int $jobId * @return void */ public function jobqueueExecute($jobId) { $this->queuedJobService->checkJobHealth(); $job = QueuedJobDescriptor::get()->byID($jobId); if ($job) { // check that we're not trying to execute something tooo soon if (strtotime($job->StartAfter) > DBDatetime::now()->getTimestamp()) { return; } $this->queuedJobService->runJob($jobId); } } } } |