예제 #1
0
 public function testStopListeningRemovesListener()
 {
     $callback = 'beforePerformEventCallback';
     $event = 'beforePerform';
     Event::listen($event, array($this, $callback));
     Event::stopListening($event, array($this, $callback));
     $job = $this->getEventTestJob();
     $this->worker->perform($job);
     $this->worker->work(0);
     $this->assertNotContains($callback, $this->callbacksHit, $event . ' callback (' . $callback . ') was called though Resque_Event::stopListening was called');
 }
예제 #2
0
파일: Job.php 프로젝트: RTLer/php-resque-ex
 /**
  * Mark the current job as having failed.
  *
  * @param $exception
  */
 public function fail($exception)
 {
     Event::trigger('onFailure', array('exception' => $exception, 'job' => $this));
     $this->updateStatus(Status::STATUS_FAILED);
     Failure::create($this->payload, $exception, $this->worker, $this->queue);
     Stat::incr('failed');
     Stat::incr('failed:' . $this->worker);
 }
예제 #3
0
 /**
  * Perform necessary actions to start a worker.
  */
 protected function startup()
 {
     $this->log(array('message' => 'Starting worker ' . $this, 'data' => array('type' => 'start', 'worker' => (string) $this)), self::LOG_TYPE_INFO);
     $this->registerSigHandlers();
     $this->pruneDeadWorkers();
     Event::trigger('beforeFirstFork', $this);
     $this->registerWorker();
 }
예제 #4
0
 /**
  * Create a new job and save it to the specified queue.
  *
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  * @param boolean $trackStatus Set to true to be able to monitor the status of a job.
  *
  * @return string
  */
 public static function enqueue($queue, $class, $args = null, $trackStatus = false)
 {
     $result = Job::create($queue, $class, $args, $trackStatus);
     if ($result) {
         Event::trigger('afterEnqueue', ['class' => $class, 'args' => $args, 'queue' => $queue]);
     }
     return $result;
 }