/** * Sets status of the job to cancelled if process controller indicates to exit. * * @return boolean */ public function doStop() { if ($this->controller->doStop()) { $this->job->setStatus(Status::CANCELLED()); return true; } return false; }
/** * {@inheritdoc} */ public function doStop() { if ($this->fallbackController != null) { return $this->fallbackController->doStop(); } pcntl_signal_dispatch(); return $this->stop; }
/** * @ParamType("seconds", type="integer") * @ParamType("logger", type="@abc.logger") * @param $seconds * @param LoggerInterface $logger */ public function sleep($seconds, LoggerInterface $logger) { $logger->info('start sleeping for {seconds}', ['seconds' => $seconds]); $start = time(); do { sleep(1); $seconds--; } while ($seconds > 0 && !$this->controller->doStop()); $logger->info('stopped sleeping after {seconds}', ['seconds' => time() - $start]); }
/** * {@inheritdoc} */ public function tick(Queue $queue, array $options = []) { // weired, no clue why this is necessary, but somehow configure is not invoked otherwise $this->doConfigure($options); if ($this->controller->doStop()) { return false; } if ($this->controller->doPause()) { return true; } return parent::tick($queue, $options); }
/** * @ReturnType("string") * @return string|null */ public function cancel() { while (!$this->controller->doStop()) { return 'running'; } return 'cancelled'; }
protected function tick(BackendInterface $backend, array $options = []) { $this->configure($options); $iterator = $backend->getIterator(); foreach ($iterator as $message) { if ($this->controller->doPause()) { return true; } if ($this->controller->doStop()) { return false; } if (microtime(true) > $this->options['max-runtime']) { return false; } $backend->handle($message, $this->notificationDispatcher); $this->eventDispatcher->dispatch(IterateEvent::EVENT_NAME, new IterateEvent($iterator, $backend, $message)); if (null !== $this->options['max-messages'] && !(bool) --$this->options['max-messages']) { return false; } } return !$this->options['stop-when-empty']; }
/** * {@inheritdoc} */ public function valid() { return !$this->controller->doStop() && $this->scheduleIterator->valid(); }