mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 05:32:20 +00:00
Added enqueue failure detection
If a job fails to be enqueued, it would be useful to know it. So now Resque actually tells us whether the enqueue action was successful or if it failed. If your job ID comes back as FALSE, it didn't enqueue. Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
This commit is contained in:
parent
1310b0661b
commit
3798fa3ba6
2 changed files with 10 additions and 3 deletions
|
@ -98,7 +98,11 @@ class Resque
|
|||
public static function push($queue, $item)
|
||||
{
|
||||
self::redis()->sadd('queues', $queue);
|
||||
self::redis()->rpush('queue:' . $queue, json_encode($item));
|
||||
if (self::redis()->rpush('queue:' . $queue, json_encode($item)) < 1)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,11 +58,14 @@ class Resque_Job
|
|||
);
|
||||
}
|
||||
$id = md5(uniqid('', true));
|
||||
Resque::push($queue, array(
|
||||
if ( ! Resque::push($queue, array(
|
||||
'class' => $class,
|
||||
'args' => array($args),
|
||||
'id' => $id,
|
||||
));
|
||||
)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if($monitor) {
|
||||
Resque_Job_Status::create($id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue