示例#1
0
 /**
  * Initialize a failed job class and save it (where appropriate).
  *
  * @param object $payload   Object containing details of the failed job.
  * @param object $exception Instance of the exception that was thrown by the failed job.
  * @param object $worker    Instance of \Resque\Worker that received the job.
  * @param string $queue     The name of the queue the job was fetched from.
  */
 public function __construct($payload, $exception, $worker, $queue)
 {
     $data = new \stdClass();
     $data->failed_at = strftime('%a %b %d %H:%M:%S %Z %Y');
     $data->payload = $payload;
     $data->exception = get_class($exception);
     $data->error = $exception->getMessage();
     $data->backtrace = explode("\n", $exception->getTraceAsString());
     $data->worker = (string) $worker;
     $data->queue = $queue;
     $data = json_encode($data);
     Resque::redis()->rpush('failed', $data);
 }
示例#2
0
 /**
  * Stop tracking the status of a job.
  */
 public function stop()
 {
     Resque::redis()->del((string) $this);
 }
示例#3
0
文件: Stat.php 项目: huang-sh/yaf.app
 /**
  * Delete a statistic with the given name.
  *
  * @param string $stat The name of the statistic to delete.
  * @return boolean True if successful, false if not.
  */
 public static function clear($stat)
 {
     return (bool) Resque::redis()->del('stat:' . $stat);
 }
示例#4
0
 /**
  * Return Redis
  *
  * @return object Redis instance
  */
 public function redis()
 {
     return Resque::redis();
 }
示例#5
0
 /**
  * Return an object describing the job this worker is currently working on.
  *
  * @return object Object with details of current job.
  */
 public function job()
 {
     $job = Resque::redis()->get('worker:' . $this);
     if (!$job) {
         return array();
     } else {
         return json_decode($job, true);
     }
 }
示例#6
0
 /**
  * Pop a job off the delayed queue for a given timestamp.
  *
  * @param DateTime|int $timestamp Instance of DateTime or UNIX timestamp.
  *
  * @return array Matching job at timestamp.
  */
 public static function nextItemForTimestamp($timestamp)
 {
     $timestamp = self::getTimestamp($timestamp);
     $key = 'delayed:' . $timestamp;
     $item = json_decode(Resque::redis()->lpop($key), true);
     self::cleanupTimestamp($key, $timestamp);
     return $item;
 }