PHP Class Scalr\System\Zmq\Cron\AbstractTask

Task queue boilerplate.
Since: 5.0.1 (10.09.2014)
Author: Vitaliy Demidov ([email protected])
Inheritance: implements Scalr\System\Zmq\Cron\TaskInterface, use trait Scalr\LoggerAwareTrait
Mostra file Open project: scalr/scalr Class Usage Examples

Protected Properties

Property Type Description
$name string Task name
$queue ArrayObject Task queue

Public Methods

Method Description
__construct ( ) Constructor
addWorker ( $address = null )
checkMemoryUsage ( )
config ( ) : object Gets config for this cron
getAuditLoggerConfig ( )
getName ( )
getReplicaAccounts ( ) : array Gets accounts to replicate a service to process its queue in the separate workers
getReplicaTypes ( string $name = 'type', string $regex = null ) : array Gets types to replicate a service to process its queue in the separate workers
getScalrService ( ) : ScalrService Gets Scalr service
isServiceRegistered ( string $serviceName = null ) : integer | boolean Checks whether service is registered with the broker
launch ( )
onCompleted ( )
onResponse ( Scalr\System\Zmq\Cron\AbstractPayload $payload )
run ( )
shutdown ( )

Protected Methods

Method Description
launchClient ( ) : integer Runs ZMQ MDP Asynchronous Client
launchWorkers ( string $address = null ) : integer It launches pool of workers

Private Methods

Method Description
_launchWorkers ( string $address = null, integer $workers = null ) : integer It launches pool of workers
terminateWorker ( integer $pid ) Terminates one worker by specified pid

Method Details

__construct() public method

Constructor
public __construct ( )

addWorker() public method

See also: Scalr\System\Zmq\Cron\TaskInterface::addWorker()
public addWorker ( $address = null )

checkMemoryUsage() public method

See also: Scalr\System\Zmq\Cron\TaskInterface::checkMemoryUsage()
public checkMemoryUsage ( )

config() public method

Gets config for this cron
public config ( ) : object
return object Returns configuration options for the task

getAuditLoggerConfig() public method

See also: Scalr\LogCollector\AuditLoggerRetrieveConfigurationInterface::getAuditLoggerConfig()

getName() public method

See also: Scalr\System\Zmq\Cron\TaskInterface::getName()
public getName ( )

getReplicaAccounts() public method

Gets accounts to replicate a service to process its queue in the separate workers
public getReplicaAccounts ( ) : array
return array Returns the list of the accounts to replicate

getReplicaTypes() public method

Gets types to replicate a service to process its queue in the separate workers
public getReplicaTypes ( string $name = 'type', string $regex = null ) : array
$name string optional The name of the replica type in the config
$regex string optional Regex to validate. It should be specified without anchors and modifiers
return array Returns the list of the types to replicate

getScalrService() public method

Gets Scalr service
public getScalrService ( ) : ScalrService
return Scalr\Model\Entity\ScalrService Returns ScalrService instance for the current task

isServiceRegistered() public method

Checks whether service is registered with the broker
public isServiceRegistered ( string $serviceName = null ) : integer | boolean
$serviceName string optional The name of the service.
return integer | boolean Returns the number of registered workers if service has been registered with the broker or boolean FALSE otherwise

launch() public method

See also: Scalr\System\Zmq\Cron\TaskInterface::launch()
public launch ( )

launchClient() protected method

Runs ZMQ MDP Asynchronous Client
protected launchClient ( ) : integer
return integer The number of launched workers

launchWorkers() protected method

It launches pool of workers
protected launchWorkers ( string $address = null ) : integer
$address string optional An address to override the service name
return integer The number of launched workers

onCompleted() public method

See also: Scalr\System\Zmq\Cron\TaskInterface::onCompleted()
public onCompleted ( )

onResponse() public method

See also: Scalr\System\Zmq\Cron\TaskInterface::onResponse()
public onResponse ( Scalr\System\Zmq\Cron\AbstractPayload $payload )
$payload Scalr\System\Zmq\Cron\AbstractPayload

run() public method

See also: Scalr\System\Zmq\Cron\TaskInterface::run()
public run ( )

shutdown() public method

See also: Scalr\System\Zmq\Cron\TaskInterface::shutdown()
public shutdown ( )

Property Details

$name protected_oe property

Task name
protected string $name
return string

$queue protected_oe property

Task queue
protected ArrayObject $queue
return ArrayObject