Skip to content

Commit

Permalink
Merge branch 'development' of github.com:mmoreramerino/GearmanBundle …
Browse files Browse the repository at this point in the history
…into development

Conflicts:
	Project/Reportings/codesniffer.log
  • Loading branch information
Marc committed Nov 28, 2011
2 parents 9b677fc + 13ff85f commit 9481701
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Command/GearmanJobDescribeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$job = $worker['job'];
$output->writeln('<info> @job\methodName : '.$job['methodName'].'</info>');
$output->writeln('<info> @job\callableName : '.$job['realCallableName'].'</info>');
$output->writeln('<info> @job\iterations : '.$job['iter'].'</info>');
$output->writeln('<info> @job\iterations : '.$job['iterations'].'</info>');
$output->writeln('<info> @job\servers :</info>');
$output->writeln('');
foreach ($job['servers'] as $name => $server) {
Expand Down
4 changes: 2 additions & 2 deletions Driver/Gearman/GearmanAnnotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class Work extends Annotation
*
* @var integer
*/
public $iter = null;
public $iterations = null;

/**
* Servers assigned for all jobs of this work to be executed
Expand Down Expand Up @@ -71,7 +71,7 @@ final class Job extends Annotation
*
* @var integer
*/
public $iter = null;
public $iterations = null;

/**
* Servers assigned for this job to be executed
Expand Down
6 changes: 5 additions & 1 deletion MmoreramerinoGearmanBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public function boot()
$gearmanCache = $this->container->get('gearman.cache');
$existsCache = $gearmanCache->existsCacheFile();

if (in_array($this->container->get('kernel')->getEnvironment(), array('back_dev', 'back_test')) || !$existsCache) {
$environmentsCacheClear = array(
'back_dev', 'back_test', 'dev', 'test',
);

if (in_array($this->container->get('kernel')->getEnvironment(), $environmentsCacheClear) || !$existsCache) {

if ($existsCache) {
$gearmanCache->emptyCache();
Expand Down
20 changes: 10 additions & 10 deletions Module/JobClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@ public function __construct( Job $methodAnnotation, \ReflectionMethod $method, W
$this->methodName = $method->getName();

$this->realCallableName = str_replace('\\', '', $callableNameClass.'~'.$this->callableName);
$this->description = (null !== $method->getDocComment()) ?
$this->description = (null !== $methodAnnotation->description) ?
$methodAnnotation->description :
'No description is defined';

if (null !== $settings['defaults']['iter']) {
$iter = (int) ($settings['defaults']['iter']);
if (null !== $settings['defaults']['iterations']) {
$iter = (int) ($settings['defaults']['iterations']);

if (null !== $classAnnotation->iter) {
$iter = (int) ($classAnnotation->iter);
if (null !== $classAnnotation->iterations) {
$iter = (int) ($classAnnotation->iterations);
}

if (null !== $methodAnnotation->iter) {
$iter = (int) ($methodAnnotation->iter);
if (null !== $methodAnnotation->iterations) {
$iter = (int) ($methodAnnotation->iterations);
}
} else {
throw new SettingValueMissingException('defaults/iter');
throw new SettingValueMissingException('defaults/iterations');
}
$this->iter = $iter;
$this->iterations = $iter;

/**
* Servers definition for job
Expand Down Expand Up @@ -117,7 +117,7 @@ public function __toCache()
'methodName' => $this->methodName,
'realCallableName' => $this->realCallableName,
'description' => $this->description,
'iter' => $this->iter,
'iterations' => $this->iterations,
'servers' => $this->servers,
);
}
Expand Down
8 changes: 4 additions & 4 deletions Project/Reportings/codesniffer.log
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Time: 0 seconds, Memory: 4.00Mb

Time: 0 seconds, Memory: 4.50Mb

Time: 1 second, Memory: 5.25Mb
Time: 0 seconds, Memory: 5.25Mb

Time: 0 seconds, Memory: 4.75Mb
Time: 1 second, Memory: 4.75Mb

Time: 0 seconds, Memory: 5.00Mb

Expand Down Expand Up @@ -40,10 +40,10 @@ Time: 0 seconds, Memory: 4.50Mb

Time: 0 seconds, Memory: 4.50Mb

Time: 0 seconds, Memory: 4.50Mb

Time: 1 second, Memory: 4.50Mb

Time: 0 seconds, Memory: 4.50Mb

Time: 0 seconds, Memory: 4.75Mb

Time: 0 seconds, Memory: 5.25Mb
Expand Down
2 changes: 1 addition & 1 deletion Project/dev.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ defaults:

# Default number of executions before job dies.
# If annotations defined, will be overwritten
iter: 150
iterations: 150
8 changes: 4 additions & 4 deletions Service/GearmanExecute.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ private function callJob(Array $worker)

$gmworker->addFunction($job['realCallableName'], array($objInstance, $job['methodName']));

$iter = isset($job['iter']) ? (int) ($job['iter']) : 0;
$shouldStop = ($iter > 0) ? true : false;
$iterations = isset($job['iterations']) ? (int) ($job['iterations']) : 0;
$shouldStop = ($iterations > 0) ? true : false;

while ($gmworker->work()) {

Expand All @@ -66,8 +66,8 @@ private function callJob(Array $worker)
}

if ($shouldStop) {
$iter--;
if ($iter <= 0) {
$iterations--;
if ($iterations <= 0) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Workers/testWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class testWorker
*
* @param \GearmanJob $job Object with job parameters
*
* @Gearman\Job(iter=3, name="test", description="This is a description") *
* @Gearman\Job(iterations=3, name="test", description="This is a description") *
*/
public function testA(\GearmanJob $job)
{
Expand Down

0 comments on commit 9481701

Please sign in to comment.