PHP Class Phalcon\Queue\Beanstalk\Extended

Extended class to access the beanstalk queue service. Supports tubes prefixes, pcntl-workers and tubes stats.
Inheritance: extends Phalcon\Queue\Beanstalk
Mostra file Open project: phalcon/incubator Class Usage Examples

Protected Properties

Property Type Description
$logger Phalcon\Logger\Adapter If provided the errors will be logged here.
$tubePrefix string Tubes prefix.
$workers array Queue handlers.

Public Methods

Method Description
__construct ( array $options = null )
addWorker ( string $tube, callable $callback ) Adds new worker to the pool.
doWork ( boolean $ignoreErrors = false ) Runs the main worker cycle.
getJobStats ( integer $job_id ) : null | array Returns information about specified job if it exists
getTubeStats ( string $tube ) : null | array Returns information about the specified tube if it exists.
getTubes ( ) : array Returns the names of all tubes on the server.
ignoreTube ( string $tube ) : null | array Returns the number of tube watched by current session.
putInTube ( string $tube, string $data, array $options = null ) : boolean | string Puts a job on the queue using specified tube.
reserveFromTube ( string $tube, integer $timeout = null ) : boolean | Phalcon\Queue\Beanstalk\Job Reserves/locks a ready job from the specified tube.

Protected Methods

Method Description
getResponseLines ( string $cmd ) : array | null Returns the result of command that wait the list in response from beanstalkd.
getTubeName ( string | null $tube ) : string Returns the tube name with prefix.
getWatchingResponse ( string $cmd ) : string | null Returns the result of command that wait the list in response from beanstalkd.

Method Details

__construct() public method

public __construct ( array $options = null )
$options array

addWorker() public method

Adds new worker to the pool.
public addWorker ( string $tube, callable $callback )
$tube string
$callback callable

doWork() public method

Runs the main worker cycle.
public doWork ( boolean $ignoreErrors = false )
$ignoreErrors boolean

getJobStats() public method

Returns information about specified job if it exists
public getJobStats ( integer $job_id ) : null | array
$job_id integer
return null | array

getResponseLines() protected method

Returns the result of command that wait the list in response from beanstalkd.
protected getResponseLines ( string $cmd ) : array | null
$cmd string
return array | null

getTubeName() protected method

Returns the tube name with prefix.
protected getTubeName ( string | null $tube ) : string
$tube string | null
return string

getTubeStats() public method

Returns information about the specified tube if it exists.
public getTubeStats ( string $tube ) : null | array
$tube string
return null | array

getTubes() public method

Returns the names of all tubes on the server.
public getTubes ( ) : array
return array

getWatchingResponse() protected method

Added on 10-Jan-2014 20:04 IST by Tapan Kumar Thapa @ [email protected]
protected getWatchingResponse ( string $cmd ) : string | null
$cmd string
return string | null

ignoreTube() public method

Example return array: ['WATCHED' => 1] Added on 10-Jan-2014 20:04 IST by Tapan Kumar Thapa @ [email protected]
public ignoreTube ( string $tube ) : null | array
$tube string
return null | array

putInTube() public method

Puts a job on the queue using specified tube.
public putInTube ( string $tube, string $data, array $options = null ) : boolean | string
$tube string
$data string
$options array
return boolean | string job id or false

reserveFromTube() public method

Reserves/locks a ready job from the specified tube.
public reserveFromTube ( string $tube, integer $timeout = null ) : boolean | Phalcon\Queue\Beanstalk\Job
$tube string
$timeout integer
return boolean | Phalcon\Queue\Beanstalk\Job

Property Details

$logger protected_oe property

If provided the errors will be logged here.
protected Adapter,Phalcon\Logger $logger
return Phalcon\Logger\Adapter

$tubePrefix protected_oe property

Tubes prefix.
protected string $tubePrefix
return string

$workers protected_oe property

Queue handlers.
protected array $workers
return array