Merge pull request #107 from danhunsaker/feature-queue-failure

Added enqueue failure detection
This commit is contained in:
Chris Boulton 2013-05-28 18:19:01 -07:00
commit 37cdec8e11
2 changed files with 9 additions and 3 deletions

View File

@ -98,7 +98,11 @@ class Resque
public static function push($queue, $item) public static function push($queue, $item)
{ {
self::redis()->sadd('queues', $queue); self::redis()->sadd('queues', $queue);
self::redis()->rpush('queue:' . $queue, json_encode($item)); $length = self::redis()->rpush('queue:' . $queue, json_encode($item));
if ($length < 1) {
return false;
}
return true;
} }
/** /**

View File

@ -58,11 +58,13 @@ class Resque_Job
); );
} }
$id = md5(uniqid('', true)); $id = md5(uniqid('', true));
Resque::push($queue, array( if (!Resque::push($queue, array(
'class' => $class, 'class' => $class,
'args' => array($args), 'args' => array($args),
'id' => $id, 'id' => $id,
)); ))) {
return false;
}
if($monitor) { if($monitor) {
Resque_Job_Status::create($id); Resque_Job_Status::create($id);