コード例 #1
0
 public function testFailedJobExceptionsAreCaught()
 {
     $payload = array('class' => FailingJob::className(), 'args' => null);
     $job = new Job('jobs', $payload);
     $job->worker = $this->worker;
     $this->worker->perform($job);
     $this->assertEquals(1, Stat::get('failed'));
     $this->assertEquals(1, Stat::get('failed:' . $this->worker));
 }
コード例 #2
0
 public function testWorkerFailsUncompletedJobsOnExit()
 {
     $worker = new Worker('jobs');
     $worker->registerWorker();
     $payload = array('class' => TestJob::className());
     $job = new Job('jobs', $payload);
     $worker->workingOn($job);
     $worker->unregisterWorker();
     $this->assertEquals(1, Stat::get('failed'));
 }
コード例 #3
0
 public function testGetUnknownStatReturns0()
 {
     $this->assertEquals(0, Stat::get('test_get_unknown'));
 }
コード例 #4
0
 /**
  * Get a statistic belonging to this worker.
  *
  * @param string $stat Statistic to fetch.
  * @return int Statistic value.
  */
 public function getStat($stat)
 {
     return Stat::get($stat . ':' . $this);
 }
コード例 #5
0
ファイル: Job.php プロジェクト: craryprimitiveman/php-resque
 /**
  * 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);
 }