PHP Class Resque_Job, php-resque

Author: Chris Boulton ([email protected])
Mostra file Open project: chrisboulton/php-resque Class Usage Examples

Public Properties

Property Type Description
$payload Array containing details of the job.
$queue The name of the queue that this job belongs to.
$worker Instance of the Resque worker running this job.

Public Methods

Method Description
__construct ( string $queue, array $payload ) Instantiate a new instance of a job.
__toString ( ) : string Generate a string representation used to describe the current job.
create ( string $queue, string $class, array $args = null, boolean $monitor = false, string $id = null ) : string Create a new job and save it to the specified queue.
fail ( $exception ) Mark the current job as having failed.
getArguments ( ) : array Get the arguments supplied to this job.
getInstance ( ) : Resque_JobInterface Get the instantiated object for this job that will be performing work.
getJobFactory ( ) : Resque_Job_FactoryInterface
getStatus ( ) : integer Return the status of the current job.
perform ( ) : boolean Actually execute a job by calling the perform method on the class associated with the job with the supplied arguments.
recreate ( ) : string Re-queue the current job.
reserve ( string $queue ) : false | object Find the next available job from the specified queue and return an instance of Resque_Job for it.
reserveBlocking ( array $queues, integer $timeout = null ) : false | object Find the next available job from the specified queues using blocking list pop and return an instance of Resque_Job for it.
setJobFactory ( Resque_Job_FactoryInterface $jobFactory ) : Resque_Job
updateStatus ( integer $status ) Update the status of the current job.

Method Details

__construct() public method

Instantiate a new instance of a job.
public __construct ( string $queue, array $payload )
$queue string The queue that the job belongs to.
$payload array array containing details of the job.

__toString() public method

Generate a string representation used to describe the current job.
public __toString ( ) : string
return string The string representation of the job.

create() public static method

Create a new job and save it to the specified queue.
public static create ( string $queue, string $class, array $args = null, boolean $monitor = false, string $id = null ) : string
$queue string The name of the queue to place the job in.
$class string The name of the class that contains the code to execute the job.
$args array Any optional arguments that should be passed when the job is executed.
$monitor boolean Set to true to be able to monitor the status of a job.
$id string Unique identifier for tracking the job. Generated if not supplied.
return string

fail() public method

Mark the current job as having failed.
public fail ( $exception )
$exception

getArguments() public method

Get the arguments supplied to this job.
public getArguments ( ) : array
return array Array of arguments.

getInstance() public method

Get the instantiated object for this job that will be performing work.
public getInstance ( ) : Resque_JobInterface
return Resque_JobInterface Instance of the object that this job belongs to.

getJobFactory() public method

public getJobFactory ( ) : Resque_Job_FactoryInterface
return Resque_Job_FactoryInterface

getStatus() public method

Return the status of the current job.
public getStatus ( ) : integer
return integer The status of the job as one of the Resque_Job_Status constants.

perform() public method

Actually execute a job by calling the perform method on the class associated with the job with the supplied arguments.
public perform ( ) : boolean
return boolean

recreate() public method

Re-queue the current job.
public recreate ( ) : string
return string

reserve() public static method

Find the next available job from the specified queue and return an instance of Resque_Job for it.
public static reserve ( string $queue ) : false | object
$queue string The name of the queue to check for a job in.
return false | object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.

reserveBlocking() public static method

Find the next available job from the specified queues using blocking list pop and return an instance of Resque_Job for it.
public static reserveBlocking ( array $queues, integer $timeout = null ) : false | object
$queues array
$timeout integer
return false | object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.

setJobFactory() public method

public setJobFactory ( Resque_Job_FactoryInterface $jobFactory ) : Resque_Job
$jobFactory Resque_Job_FactoryInterface
return Resque_Job

updateStatus() public method

Update the status of the current job.
public updateStatus ( integer $status )
$status integer Status constant from Resque_Job_Status indicating the current status of a job.

Property Details

$payload public_oe property

Array containing details of the job.
public $payload

$queue public_oe property

The name of the queue that this job belongs to.
public $queue

$worker public_oe property

Instance of the Resque worker running this job.
public $worker