예제 #1
0
파일: Job.php 프로젝트: snikius/php-resque
 /**
  * Mark the current job as having failed.
  *
  * @param $exception
  */
 public function fail($exception)
 {
     Resque_Event::trigger('onFailure', array('exception' => $exception, 'job' => $this));
     $this->updateStatus(Resque_Job_Status::STATUS_FAILED);
     Resque_Failure::create($this->payload, $exception, $this->worker, $this->queue);
     Resque_Stat::incr('failed');
     Resque_Stat::incr('failed:' . $this->worker);
 }
예제 #2
0
파일: StatTest.php 프로젝트: zhangsong/yii
 public function testGetStatByName()
 {
     Resque_Stat::incr('test_get', 100);
     $this->assertEquals(100, Resque_Stat::get('test_get'));
 }
예제 #3
0
 /**
  * Notify Redis that we've finished working on a job, clearing the working
  * state and incrementing the job stats.
  */
 public function doneWorking()
 {
     $this->currentJob = null;
     Resque_Stat::incr('processed');
     Resque_Stat::incr('processed:' . (string) $this);
     Resque::redis()->del('worker:' . (string) $this);
 }
예제 #4
0
 /**
  * Increment the value of the specified statistic by a certain amount (default is 1)
  *
  * @param string $stat The name of the statistic to increment.
  * @param int $by The amount to increment the statistic by.
  * @return boolean True if successful, false if not.
  */
 public static function incr($stat = self::KEYNAME, $by = 1)
 {
     return parent::incr($stat, $by);
 }
 /**
  * Mark the current job as having failed.
  *
  * @param $exception
  */
 public function fail($exception)
 {
     Resque_Event::trigger('onFailure', array('exception' => $exception, 'job' => $this));
     // job的状态更新成failed
     $this->updateStatus(Resque_Job_Status::STATUS_FAILED);
     require_once dirname(__FILE__) . '/Failure.php';
     // 记录信息到failed队列中
     Resque_Failure::create($this->payload, $exception, $this->worker, $this->queue);
     // 失败状态的个数+1
     Resque_Stat::incr('failed');
     Resque_Stat::incr('failed:' . $this->worker);
 }