コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function doStop()
 {
     if ($this->fallbackController != null) {
         return $this->fallbackController->doStop();
     }
     pcntl_signal_dispatch();
     return $this->stop;
 }
コード例 #3
0
ファイル: Sleeper.php プロジェクト: aboutcoders/job-bundle
 /**
  * @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]);
 }
コード例 #4
0
 /**
  * {@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);
 }
コード例 #5
0
ファイル: TestJob.php プロジェクト: aboutcoders/job-bundle
 /**
  * @ReturnType("string")
  * @return string|null
  */
 public function cancel()
 {
     while (!$this->controller->doStop()) {
         return 'running';
     }
     return 'cancelled';
 }
コード例 #6
0
 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'];
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function valid()
 {
     return !$this->controller->doStop() && $this->scheduleIterator->valid();
 }