This commit is contained in:
Ruud Kamphuis 2013-03-12 11:18:37 +01:00
parent ff0d2bc655
commit 132531e1a2
7 changed files with 150 additions and 102 deletions

View file

@ -71,22 +71,41 @@ class Resque_Job
return $id;
}
/**
* Find the next available job from the specified queue and return an
* instance of Resque_Job for it.
*
* @param string $queue The name of the queue to check for a job in.
* @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
*/
public static function reserve($queue, $interval = null)
{
$payload = Resque::pop($queue, $interval);
if(!is_array($payload)) {
return false;
}
/**
* Find the next available job from the specified queue and return an
* instance of Resque_Job for it.
*
* @param string $queue The name of the queue to check for a job in.
* @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
*/
public static function reserve($queue)
{
$payload = Resque::pop($queue);
if(!is_array($payload)) {
return false;
}
return new Resque_Job($queue, $payload);
}
return new Resque_Job($queue, $payload);
}
/**
* Find the next available job from the specified queue and return an
* instance of Resque_Job for it.
*
* @param string $queue The name of the queue to check for a job in.
* @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
*/
public static function reserveBlocking($queues, $interval = null)
{
$payload = Resque::blpop($queues, $interval);
if(!is_array($payload)) {
return false;
}
var_dump($payload);
return new Resque_Job($payload->queue, $payload);
}
/**
* Update the status of the current job.