Example #1
0
 /**
  * @param Application $application
  */
 public function run(Application $application)
 {
     foreach ($this->workers as $name => $options) {
         $worker = $this->getServiceLocator()->get($name);
         if (!$worker instanceof JobInterface) {
             throw new \Exception("Error Bootstrapping German Manager, " . $name . " not an instance of JobInterface.");
         }
         $application->add($worker);
     }
 }
Example #2
0
 public function testApplication()
 {
     $process = new Process($this->config);
     $application = new Application($this->config, $process);
     $application->add(new MockJob());
     $application->run();
     $test = $process->isRunning();
     $this->assertTrue($test);
     $process->stop();
 }
 /**
  * @return Application
  * @throws \yii\base\InvalidConfigException
  */
 public function getApplication()
 {
     if ($this->_application === null) {
         $app = new Application($this->getConfig(), $this->getProcess());
         foreach ($this->getJobs() as $name => $job) {
             $job = Yii::createObject($job);
             if (!$job instanceof JobInterface) {
                 throw new \yii\base\InvalidConfigException('Gearman job must be instance of JobInterface.');
             }
             $job->setName($name);
             $app->add($job);
         }
         $this->_application = $app;
     }
     return $this->_application;
 }