Browse Source

Some changes for refactoring

Marc 11 years ago
parent
commit
be531ac170

+ 7 - 2
Command/GearmanCacheClearCommand.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Command;
 
 use Symfony\Component\Console\Input\InputOption;
@@ -12,8 +19,6 @@ use Mmoreram\GearmanBundle\Service\GearmanSettings;
 use Mmoreram\GearmanBundle\Module\GearmanBaseBundle;
 use Mmoreram\GearmanBundle\Service\GearmanCacheLoader;
 use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
-use Mmoreram\GearmanBundle\Exceptions\GearmanNotInstalledException;
-use Mmoreram\GearmanBundle\Exceptions\NoSettingsFileExistsException;
 
 
 /**

+ 7 - 2
Command/GearmanCacheWarmupCommand.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Command;
 
 use Symfony\Component\Console\Input\InputOption;
@@ -12,8 +19,6 @@ use Mmoreram\GearmanBundle\Service\GearmanSettings;
 use Mmoreram\GearmanBundle\Module\GearmanBaseBundle;
 use Mmoreram\GearmanBundle\Service\GearmanCacheLoader;
 use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
-use Mmoreram\GearmanBundle\Exceptions\GearmanNotInstalledException;
-use Mmoreram\GearmanBundle\Exceptions\NoSettingsFileExistsException;
 
 
 /**

+ 7 - 0
Command/GearmanJobDescribeCommand.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Command;
 
 use Symfony\Component\Console\Input\InputOption;

+ 7 - 0
Command/GearmanJobExecuteCommand.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Command;
 
 use Symfony\Component\Console\Input\InputOption;

+ 7 - 0
Command/GearmanWorkerDescribeCommand.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Command;
 
 use Symfony\Component\Console\Input\InputOption;

+ 7 - 0
Command/GearmanWorkerExecuteCommand.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Command;
 
 use Symfony\Component\Console\Input\InputOption;

+ 7 - 0
Command/GearmanWorkerListCommand.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Command;
 
 use Symfony\Component\Console\Input\InputOption;

+ 10 - 3
DependencyInjection/Configuration.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\DependencyInjection;
 
 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
@@ -47,17 +54,17 @@ class Configuration implements ConfigurationInterface
                     ->defaultValue(array(
                         'localhost' =>  array(
                             'hostname'  =>  '127.0.0.1',
-                            'port'      =>  4730,
+                            'port'      =>  "4730",
                         )
                     ))
                     ->prototype('array')
                         ->children()
-                            ->scalarNode('hostname')
+                            ->scalarNode('host')
                                 ->isRequired()
                                 ->cannotBeEmpty()
                             ->end()
                             ->scalarNode('port')
-                                ->defaultValue(4730)
+                                ->defaultValue("4730")
                             ->end()
                         ->end()
                     ->end()

+ 7 - 0
DependencyInjection/GearmanExtension.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\DependencyInjection;
 
 use Symfony\Component\Config\FileLocator;

+ 6 - 2
Driver/Gearman/Job.php

@@ -1,16 +1,20 @@
 <?php
 
 /**
- * Gearman annotations driver
- *
+ * Gearman Bundle for Symfony2
+ * 
  * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
  */
 
 namespace Mmoreram\GearmanBundle\Driver\Gearman;
 
 use Doctrine\Common\Annotations\Annotation;
 
+
 /**
+ * Gearman Job annotation driver
+ * 
  * @Annotation
  */
 final class Job extends Annotation

+ 5 - 2
Driver/Gearman/Work.php

@@ -1,9 +1,10 @@
 <?php
 
 /**
- * Gearman annotations driver
- *
+ * Gearman Bundle for Symfony2
+ * 
  * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
  */
 
 namespace Mmoreram\GearmanBundle\Driver\Gearman;
@@ -11,6 +12,8 @@ namespace Mmoreram\GearmanBundle\Driver\Gearman;
 use Doctrine\Common\Annotations\Annotation;
 
 /**
+ * Gearman Work annotation driver
+ * 
  * @Annotation 
  */
 final class Work extends Annotation

+ 10 - 5
Exceptions/JobDoesNotExistException.php

@@ -1,13 +1,18 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Exceptions;
 
 use Exception;
 
 /**
  * GearmanBundle can't find job specified as Gearman format Exception
- *
- * @author Marc Morera <yuhu@mmoreram.com>
  */
 class JobDoesNotExistException extends Exception
 {
@@ -15,9 +20,9 @@ class JobDoesNotExistException extends Exception
     /**
      * Construct method for Exception
      *
-     * @param string     $job      Job name to be shown in Exception
-     * @param integer    $code     Code of exception
-     * @param \Exception $previous Previos Exception
+     * @param string    $job      Job name to be shown in Exception
+     * @param integer   $code     Code of exception
+     * @param Exception $previous Previos Exception
      */
     public function __construct($job, $code = 0, Exception $previous = null)
     {

+ 10 - 5
Exceptions/NoCallableGearmanMethodException.php

@@ -1,13 +1,18 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Exceptions;
 
 use Exception;
 
 /**
  * GearmanBundle can't find calling method
- *
- * @author Marc Morera <yuhu@mmoreram.com>
  */
 class NoCallableGearmanMethodException extends Exception
 {
@@ -15,9 +20,9 @@ class NoCallableGearmanMethodException extends Exception
     /**
      * Construct method for Exception
      *
-     * @param string     $calledMethod Called and not found method
-     * @param integer    $code         Code of exception
-     * @param \Exception $previous     Previos Exception
+     * @param string    $calledMethod Called and not found method
+     * @param integer   $code         Code of exception
+     * @param Exception $previous     Previos Exception
      */
     public function __construct($calledMethod='', $code = 0, Exception $previous = null)
     {

+ 0 - 28
Exceptions/NoSettingsFileExistsException.php

@@ -1,28 +0,0 @@
-<?php
-
-namespace Mmoreram\GearmanBundle\Exceptions;
-
-use Exception;
-
-/**
- * GearmanBundle can't find settings into specified path Exception
- *
- * @author Marc Morera <yuhu@mmoreram.com>
- */
-class NoSettingsFileExistsException extends Exception
-{
-
-    /**
-     * Construct method for Exception
-     *
-     * @param string     $path     Path of setting file not found
-     * @param integer    $code     Code of exception
-     * @param \Exception $previous Previos Exception
-     */
-    public function __construct($path, $code = 0, Exception $previous = null)
-    {
-        $message = 'GearmanBundle can\'t find settings file in path "' . $path . '"' . PHP_EOL;
-
-        parent::__construct($message, $code, $previous);
-    }
-}

+ 0 - 28
Exceptions/SettingValueBadFormatException.php

@@ -1,28 +0,0 @@
-<?php
-
-namespace Mmoreram\GearmanBundle\Exceptions;
-
-use Exception;
-
-/**
- * GearmanBundle setting is not well formatted
- *
- * @author Marc Morera <yuhu@mmoreram.com>
- */
-class SettingValueBadFormatException extends Exception
-{
-
-    /**
-     * Construct method for Exception
-     *
-     * @param string     $value    Setting value bad formatted
-     * @param integer    $code     Code of exception
-     * @param \Exception $previous Previos Exception
-     */
-    public function __construct($value, $code = 0, Exception $previous = null)
-    {
-        $message = 'GearmanBundle setting "' . $value . '" is not well formatted' . PHP_EOL;
-
-        parent::__construct($message, $code, $previous);
-    }
-}

+ 0 - 28
Exceptions/SettingValueMissingException.php

@@ -1,28 +0,0 @@
-<?php
-
-namespace Mmoreram\GearmanBundle\Exceptions;
-
-use Exception;
-
-/**
- * GearmanBundle can't find setting value
- *
- * @author Marc Morera <yuhu@mmoreram.com>
- */
-class SettingValueMissingException extends Exception
-{
-
-    /**
-     * Construct method for Exception
-     *
-     * @param string     $value    Setting value not found
-     * @param integer    $code     Code of exception
-     * @param \Exception $previous Previos Exception
-     */
-    public function __construct($value, $code = 0, Exception $previous = null)
-    {
-        $message = 'GearmanBundle can\'t find setting value "' . $value . '"' . PHP_EOL;
-
-        parent::__construct($message, $code, $previous);
-    }
-}

+ 10 - 5
Exceptions/WorkerDoesNotExistException.php

@@ -1,13 +1,18 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Exceptions;
 
 use Exception;
 
 /**
  * GearmanBundle can't find worker specified as Gearman format Exception
- *
- * @author Marc Morera <yuhu@mmoreram.com>
  */
 class WorkerDoesNotExistException extends Exception
 {
@@ -15,9 +20,9 @@ class WorkerDoesNotExistException extends Exception
     /**
      * Construct method for Exception
      *
-     * @param string     $worker   Worker name to be shown in Exception
-     * @param integer    $code     Code of exception
-     * @param \Exception $previous Previos Exception
+     * @param string    $worker   Worker name to be shown in Exception
+     * @param integer   $code     Code of exception
+     * @param Exception $previous Previos Exception
      */
     public function __construct($worker, $code = 0, Exception $previous = null)
     {

+ 7 - 0
GearmanBundle.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle;
 
 use Symfony\Component\HttpKernel\Bundle\Bundle;

+ 9 - 4
Module/JobClass.php

@@ -1,18 +1,23 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Module;
 
 use Mmoreram\GearmanBundle\Driver\Gearman\Job;
 use Mmoreram\GearmanBundle\Driver\Gearman\Work;
 use Symfony\Component\DependencyInjection\ContainerAware;
-use Mmoreram\GearmanBundle\Exceptions\SettingValueMissingException;
-use Mmoreram\GearmanBundle\Exceptions\SettingValueBadFormatException;
 use ReflectionMethod;
 
 /**
  * Job class
- *
- * @author Marc Morera <yuhu@mmoreram.com>
+ * 
+ * This class provide all worker definition.
  */
 class JobClass extends ContainerAware
 {

+ 0 - 2
Module/JobCollection.php

@@ -6,8 +6,6 @@ use Mmoreram\GearmanBundle\Module\JobClass as Job;
 
 /**
  * Job Collection class
- *
- * @author Marc Morera <yuhu@mmoreram.com>
  */
 class JobCollection
 {

+ 7 - 7
Module/WorkerClass.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Module;
 
 use Doctrine\Common\Annotations\Reader;
@@ -14,13 +21,6 @@ use ReflectionMethod;
  * Worker class
  * 
  * This class provide all worker definition.
- * 
- * * JobCollection - All worker available jobs
- * * CallableName - Friendly way to call this worker
- * * Namespace - Worker namespace
- * * Servers - Servers defined for this worker
- *
- * @author Marc Morera <yuhu@mmoreram.com>
  */
 class WorkerClass
 {

+ 7 - 2
Module/WorkerCollection.php

@@ -1,13 +1,18 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Module;
 
 use Mmoreram\GearmanBundle\Module\WorkerClass as Worker;
 
 /**
  * WorkerCollection class
- *
- * @author Marc Morera <yuhu@mmoreram.com>
  */
 class WorkerCollection
 {

+ 7 - 2
Module/WorkerDirectoryLoader.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Module;
 
 use Symfony\Component\Config\FileLocator;
@@ -8,8 +15,6 @@ use Symfony\Component\Config\Resource\DirectoryResource;
 
 /**
  * Worker directory loader class
- *
- * @author Marc Morera <yuhu@mmoreram.com>
  */
 class WorkerDirectoryLoader extends FileLoader
 {

+ 208 - 2
README.md

@@ -1,6 +1,6 @@
 #GearmanBundle for Symfony2
 
-###Installing [GearmanBundle](https://github.com/mmoreram/gearman-bundle)
+##Installation
 You have to add require line into you composer.json file
 
     "require": {
@@ -18,6 +18,212 @@ And register the bundle in your appkernel.php file
 
     return array(
         // ...
+        new Liip\DoctrineCacheBundle\LiipDoctrineCacheBundle(),
         new Mmoreram\GearmanBundle\GearmanBundle(),
         // ...
-    );
+    );
+
+##Configuration
+We must configure our Worker. Common definitions must be defined in config.yml file, setting values for all installed Workers. 
+Also we must config gearman cache, using doctrine cache.
+    
+    liip_doctrine_cache:
+        namespaces:
+            gearman:
+                type: file_system
+
+
+    gearman:
+        # Bundles will parsed searching workers
+        bundles:
+            # Name of bundle
+            AcmeBundle:
+
+                # Bundle namespace
+                namespace: Mmoreramerino\TestBundle
+
+                # Bundle search can be enabled or disabled
+                active: true
+
+                # If any include is defined, Only these namespaces will be parsed
+                # Otherwise, full Bundle will be parsed
+                include:
+                    - Services
+                    - EventListener
+
+                # Namespaces this Bundle will ignore when parsing
+                ignore:
+                    - DependencyInjection
+                    - Resources
+
+        # default values
+        # All these values will be used if are not overwritten in Workers or jobs
+        defaults:
+
+            # default method related with all jobs
+            # do
+            # doBackground
+            # doHigh
+            # doHighBackground
+            # doLow
+            # doLowBackground
+            method: do
+
+            # Default number of executions before job dies.
+            # If annotations defined, will be overwritten
+            # If empty, 150 is defined by default
+            iterations: 150
+
+        # Server list where workers and clients will connect to
+        # Each server must contain host and port
+        # If annotations defined, will be full overwritten
+        #
+        # If servers empty, simple localhost server is defined by default
+        # If port empty, 4730 is defined by efault
+        servers:
+            localhost:
+                host: 127.0.0.1
+                port: 4730
+
+In development mode you do not want to cache things over more than one request. An easy solution for this is to use the array cache in the dev environment ( Extracted from [LiipDoctrineCacheBundle](https://github.com/liip/LiipDoctrineCacheBundle#development-mode) documentation )
+
+    #config.yml
+    liip_doctrine_cache:
+        namespaces:
+            presta_sitemap:
+                type: file_system
+
+    # config_dev.yml
+    liip_doctrine_cache:
+        namespaces:
+            presta_sitemap:
+                type: array
+
+## Defining your workers
+This Bundle allows you to configure whatever as a Job. It provides you an easy way to execute it with Supervisor, for example. Moreover, it let you call client methods in Symfony2 environment in a really simple and practical way.  
+Job annotations always overwrite work annotations, and work annotations always overwrite environment settings.
+
+    <?php
+
+    namespace Acme\AcmeBundle\Workers; 
+
+    use Mmoreram\GearmanBundle\Driver\Gearman; 
+
+    /**
+     * @Gearman\Work(
+     *     iterations = 3, 
+     *     description = "Worker test description",
+     *     defaultMethod = "do",
+     *     servers = (
+     *         ( "host": "192.168.1.1", "port": 4560 ),
+     *         ( "host": "192.168.1.2", "port": 4560 ), 
+     *     )
+     * )
+     */
+    class AcmeWorker
+    {
+        /**
+        * Test method to run as a job
+        *
+        * @param \GearmanJob $job Object with job parameters
+        *
+        * @return boolean
+        *
+        * @Gearman\Job(
+        *     iterations = 3, 
+        *     name = "test", 
+        *     description = "This is a description"
+        * )
+        */
+        public function testA(\GearmanJob $job)
+        {
+            echo 'Job testA done!' . PHP_EOL;
+
+            return true;
+        }
+
+        /**
+        * Test method to run as a job
+        *
+        * @param \GearmanJob $job Object with job parameters
+        *
+        * @return boolean
+        *
+        * @Gearman\Job(
+        *     defaultMethod = "doLowBackground"
+        * )
+        */
+        public function testA(\GearmanJob $job)
+        {
+            echo 'Job testB done!' . PHP_EOL;
+
+            return true;
+        }
+    }
+
+### Worker Annotations
+
+* name : Name of work. You can associate a group of jobs with some keyword
+* description : Short description about all jobs inside
+* iterations : You can overwrite iterations of all jobs inside
+* servers : array containing servers providers will connect to offer all jobs
+* service : You can use even a service. Must specify callable service name
+* defaultMethod : You can define witch method will be used as default in all jobs
+
+### Job Annotations
+
+* name : Name of job. You will use it to call job
+* description : Short description about this job. Important field
+* iterations : You can overwrite iterations of this job.
+* servers : array containing servers providers will connect to offer this job
+* defaultMethod : You can define witch method will be used as default in this job
+
+### Service as a Worker
+
+If you want to use your service as a worker, you have to specify service variable in Worker annotation
+
+    <?php
+
+    namespace Acme\AcmeBundle\Services; 
+
+    /**
+     * @Gearman\Work(
+     *     service="myServiceName"
+     * )
+     */
+    class AcmeService
+    {
+ 
+        ... some code ...
+
+        /**
+        * Test method to run as a job
+        *
+        * @param \GearmanJob $job Object with job parameters
+        *
+        * @return boolean
+        *
+        * @Gearman\Job()
+        */
+        public function testA(\GearmanJob $job)
+        {
+            echo 'Job testB done!' . PHP_EOL;
+
+            return true;
+        }
+    }
+
+And have this service defined in your dependency injection definition file
+
+    # /Resources/config/services.yml
+    bundles:
+        Services:
+            myServiceName:
+                class: Acme\AcmeBundle\Services\AcmeService
+                arguments: 
+                    event_dispatcher: @event_dispatcher
+                    mailer: @mailer
+
+### Executing your workers
+
+Once all your workers are defined, you can simply 

+ 7 - 0
Service/Abstracts/AbstractGearmanService.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Service\Abstracts;
 
 use Mmoreram\GearmanBundle\Service\GearmanCacheWrapper;

+ 7 - 0
Service/GearmanCacheWrapper.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Service;
 
 use Symfony\Component\Config\FileLocator;

+ 12 - 18
Service/GearmanClient.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Service;
 
 use Mmoreram\GearmanBundle\Service\Abstracts\AbstractGearmanService;
@@ -68,6 +75,7 @@ class GearmanClient extends AbstractGearmanService
     private function enqueue($jobName, $params, $method, $unique)
     {
         $worker = $this->getJob($jobName);
+        
         if (false !== $worker) {
             return $this->doEnqueue($worker, $params, $method, $unique);
         }
@@ -95,7 +103,7 @@ class GearmanClient extends AbstractGearmanService
         $gmclient = new \GearmanClient();
         $this->assignServers($gmclient);
 
-        return $gmclient->$method($worker['job']['realCallableName'], serialize($params), $unique);
+        return $gmclient->$method($worker['job']['realCallableName'], $params, $unique);
     }
 
 
@@ -414,7 +422,7 @@ class GearmanClient extends AbstractGearmanService
             'context'   =>  $context,
             'unique'    =>  $unique,
             'method'    =>  $method,
-            );
+        );
 
         $this->addTaskToStructure($task);
 
@@ -451,32 +459,18 @@ class GearmanClient extends AbstractGearmanService
         $this->assignServers($gearmanClient);
 
         foreach ($this->taskStructure as $task) {
-
             $type = $task['method'];
             $jobName = $task['name'];
             $worker = $this->getJob($jobName);
 
             if (false !== $worker) {
 
-                $gearmanClient->$type($worker['job']['realCallableName'], serialize($task['params']), $task['context'], $task['unique']);
+                $gearmanClient->$type($worker['job']['realCallableName'], $task['params'], $task['context'], $task['unique']);
             }
         }
 
-        $this->resetTaskStructure();
-
-        return $gearmanClient->runTasks();
-    }
-
-
-    /**
-     * Reset all tasks structure. Remove all set values
-     *
-     * @return GearmanClient self Object
-     */
-    public function resetTaskStructure()
-    {
         $this->taskStructure = array();
 
-        return $this;
+        return $gearmanClient->runTasks();
     }
 }

+ 7 - 0
Service/GearmanDescriber.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Service;
 
 use Symfony\Component\Console\Output\OutputInterface;

+ 10 - 4
Service/GearmanExecute.php

@@ -1,11 +1,17 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Service;
 
 use Mmoreram\GearmanBundle\Service\Abstracts\AbstractGearmanService;
 use Symfony\Component\DependencyInjection\Container;
 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
-use GearmanWorker;
 
 /**
  * Gearman execute methods. All Worker methods
@@ -58,7 +64,7 @@ class GearmanExecute extends AbstractGearmanService
      */
     private function callJob(Array $worker)
     {
-        $gearmanWorker= new GearmanWorker();
+        $gearmanWorker = new \GearmanWorker();
 
         if (isset($worker['job'])) {
 
@@ -129,8 +135,8 @@ class GearmanExecute extends AbstractGearmanService
         if (!empty($servers)) {
 
             foreach ($servers as $server) {
-                list($addr, $port) = explode(':', $server, 2);
-                $gmworker->addServer($addr, $port);
+
+                $gmworker->addServer($server['host'], $server['port']);
             }
         } else {
             $gmworker->addServer();

+ 7 - 0
Workers/testWorker.php

@@ -1,5 +1,12 @@
 <?php
 
+/**
+ * Gearman Bundle for Symfony2
+ * 
+ * @author Marc Morera <yuhu@mmoreram.com>
+ * @since 2013
+ */
+
 namespace Mmoreram\GearmanBundle\Workers;
 
 use Mmoreram\GearmanBundle\Driver\Gearman;

+ 2 - 1
composer.json

@@ -21,7 +21,8 @@
     "require": {
         "php": ">=5.3.2",
         "symfony/framework-bundle": ">=2.0",
-        "liip/doctrine-cache-bundle": "dev-master"
+        "liip/doctrine-cache-bundle": "dev-master",
+        "ext-gearman": "*",
     },
     "target-dir": "Mmoreram/GearmanBundle",
     "autoload": {