/** * @param Job $job * @param CronEvent $event * @return AbstractEvent */ private function handleCronEvent(Job $job, CronEvent $event) : AbstractEvent { if (!$event->isPropagationStopped()) { $nextRun = $this->cron->getNextRun($event->getExpression()); $job->setTimestamp($nextRun); $this->gateway->addJob($job); } return $event->getEvent(); }
/** * @Route("/stats/", name="status.index") */ public function index() : array { $stats = $this->stats->getAll(); try { $redisStats = $this->getRedis()->info(); } catch (PredisException $e) { $redisStats = []; } return ['jobs' => $this->messageQueue->getEventsByType(), 'stats' => $stats, 'redis' => $redisStats]; }
/** * @return array */ protected function getCrons() : array { $crons = $this->includeFile(Cron::CACHE_FILE); if (empty($crons)) { return []; } foreach ($this->gateway->getEventsByType(CronEvent::CRON) as $id => $job) { /** @var CronEvent $event */ $event = $job->getEvent(); /** @var TimingEvent $timingEvent */ $timingEvent = $event->getEvent(); $name = $timingEvent->getTimingId(); if (isset($crons[$name])) { unset($crons[$name]); } } return $crons; }
/** * @param BackgroundEvent $event */ public function onBackgroundEvent(BackgroundEvent $event) { $this->gateway->addEvent($event->getEvent(), 0); }
/** * @Route("/jobs/{eventId}:{jobId}/", methods="DELETE", name="messageQueue.deleteJob", requirements={"jobId":"\d+"}) * @param Request $request * @param string $eventType * @param int $jobId * @return bool */ public function deleteJob(Request $request, string $eventType, int $jobId) : bool { unset($request); return $this->gateway->deleteEvent($jobId, $eventType); }