Beispiel #1
0
 /**
  * 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);
 }
Beispiel #2
0
 public function testGetStatByName()
 {
     Resque_Stat::incr('test_get', 100);
     $this->assertEquals(100, Resque_Stat::get('test_get'));
 }
Beispiel #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);
 }
 /**
  * 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);
 }