PHP Class Mmoreram\GearmanBundle\Service\GearmanExecute

Since: 2.3.1
Inheritance: extends Mmoreram\GearmanBundle\Service\Abstracts\AbstractGearmanService
显示文件 Open project: mmoreram/gearman-bundle Class Usage Examples

Protected Properties

Property Type Description
$eventDispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface EventDispatcher instance
$executeOptionsResolver Symfony\Component\OptionsResolver\OptionsResolver
$output Symfony\Component\Console\Output\OutputInterface Output instance
$stopWorkSignalReceived boolean Boolean to track if a system signal has been received

Public Methods

Method Description
__construct ( Mmoreram\GearmanBundle\Service\GearmanCacheWrapper $gearmanCacheWrapper, array $defaultSettings ) Construct method
executeJob ( string $jobName, array $options = [], GearmanWorker $gearmanWorker = null ) Executes a job given a jobName and given settings and annotations of job
executeWorker ( string $workerName, array $options = [] ) Executes a worker given a workerName subscribing all his jobs inside and given settings and annotations of worker and jobs
handleJob ( GearmanJob $job, mixed $context ) : mixed Wrapper function handler for all registered functions This allows us to do some nice logging when jobs are started/finished
handleSystemSignal ( $signo ) Toggles that work should be stopped, we only subscribe to SIGTERM and SIGHUP
setContainer ( Symfony\Component\DependencyInjection\ContainerInterface $container ) : GearmanExecute Set container
setEventDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher ) : GearmanExecute Set event dispatcher
setOutput ( Symfony\Component\Console\Output\OutputInterface $output ) : GearmanExecute Set output

Private Methods

Method Description
addServers ( GearmanWorker $gmworker, array $servers ) : array Adds into worker all defined Servers.
callJob ( array $worker, array $options = [], GearmanWorker $gearmanWorker = null ) : GearmanExecute Given a worker, execute GearmanWorker function defined by job.
createJob ( array $worker ) : Object Given a worker settings, return Job instance
runJob ( GearmanWorker $gearmanWorker, Object $objInstance, array $jobs, integer $iterations, integer $timeout = null ) : GearmanExecute Given a GearmanWorker and an instance of Job, run it

Method Details

__construct() public method

Construct method
public __construct ( Mmoreram\GearmanBundle\Service\GearmanCacheWrapper $gearmanCacheWrapper, array $defaultSettings )
$gearmanCacheWrapper Mmoreram\GearmanBundle\Service\GearmanCacheWrapper GearmanCacheWrapper
$defaultSettings array The default settings for the bundle

executeJob() public method

Executes a job given a jobName and given settings and annotations of job
public executeJob ( string $jobName, array $options = [], GearmanWorker $gearmanWorker = null )
$jobName string Name of job to be executed
$options array Array of options passed to the callback
$gearmanWorker GearmanWorker Worker instance to use

executeWorker() public method

Executes a worker given a workerName subscribing all his jobs inside and given settings and annotations of worker and jobs
public executeWorker ( string $workerName, array $options = [] )
$workerName string Name of worker to be executed
$options array

handleJob() public method

Wrapper function handler for all registered functions This allows us to do some nice logging when jobs are started/finished
See also: https://github.com/brianlmoon/GearmanManager/blob/ffc828dac2547aff76cb4962bb3fcc4f454ec8a2/GearmanPeclManager.php#L95-206
public handleJob ( GearmanJob $job, mixed $context ) : mixed
$job GearmanJob
$context mixed
return mixed

handleSystemSignal() public method

Toggles that work should be stopped, we only subscribe to SIGTERM and SIGHUP
public handleSystemSignal ( $signo )

setContainer() public method

Set container
public setContainer ( Symfony\Component\DependencyInjection\ContainerInterface $container ) : GearmanExecute
$container Symfony\Component\DependencyInjection\ContainerInterface Container
return GearmanExecute self Object

setEventDispatcher() public method

Set event dispatcher
public setEventDispatcher ( Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher ) : GearmanExecute
$eventDispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface
return GearmanExecute self Object

setOutput() public method

Set output
public setOutput ( Symfony\Component\Console\Output\OutputInterface $output ) : GearmanExecute
$output Symfony\Component\Console\Output\OutputInterface
return GearmanExecute self Object

Property Details

$eventDispatcher protected_oe property

EventDispatcher instance
protected EventDispatcherInterface,Symfony\Component\EventDispatcher $eventDispatcher
return Symfony\Component\EventDispatcher\EventDispatcherInterface

$executeOptionsResolver protected_oe property

protected OptionsResolver,Symfony\Component\OptionsResolver $executeOptionsResolver
return Symfony\Component\OptionsResolver\OptionsResolver

$output protected_oe property

Output instance
protected OutputInterface,Symfony\Component\Console\Output $output
return Symfony\Component\Console\Output\OutputInterface

$stopWorkSignalReceived protected_oe property

Boolean to track if a system signal has been received
protected bool $stopWorkSignalReceived
return boolean