PHP Class illuminate\queue\ Worker Code Examples

PHP illuminate\queue\Worker - 3 examples found. These are the top rated real world PHP examples of class illuminate\queue\Worker extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
0
 /**
  * Run the worker instance.
  *
  * @param  string  $connection
  * @param  string  $queue
  * @param  int  $delay
  * @param  int  $memory
  * @param  bool  $daemon
  * @return array
  */
 protected function runWorker($connection, $queue, $delay, $memory, $daemon = false)
 {
     if ($daemon) {
         $this->worker->setCache($this->laravel['cache']->driver());
         $this->worker->setDaemonExceptionHandler($this->laravel['Illuminate\\Contracts\\Debug\\ExceptionHandler']);
         return $this->worker->daemon($connection, $queue, $delay, $memory, $this->option('sleep'), $this->option('tries'));
     }
     return $this->worker->pop($connection, $queue, $delay, $this->option('sleep'), $this->option('tries'));
 }
 /**
  *  Process the job
  * 
  */
 protected function processJob($connectionName, $id)
 {
     $manager = $this->worker->getManager();
     $connection = $manager->connection($connectionName);
     $job = $connection->getJobFromId($id);
     // If we're able to pull a job off of the stack, we will process it and
     // then immediately return back out. If there is no job on the queue
     // we will "sleep" the worker for the specified number of seconds.
     if (!is_null($job)) {
         $sleep = max($job->getDatabaseJob()->available_at - time(), 0);
         sleep($sleep);
         return $this->worker->process($manager->getName($connectionName), $job);
     }
     return ['job' => null, 'failed' => false];
 }
Example #3
0
 /**
  * Run the worker instance.
  *
  * @param  string  $connection
  * @param  string  $queue
  * @return array
  */
 protected function runWorker($connection, $queue)
 {
     $this->worker->setCache($this->laravel['cache']->driver());
     $method = $this->option('once') ? 'runNextJob' : 'daemon';
     return $this->worker->{$method}($connection, $queue, $this->gatherWorkerOptions());
 }