getFactoryMethod() public method

public getFactoryMethod ( )
Example #1
0
 /**
  * @throws Comos\Qpm\Supervision\StopSignal
  */
 protected function _startOne()
 {
     Logger::debug(__METHOD__ . '()');
     $target = null;
     try {
         $target = \call_user_func($this->_config->getFactoryMethod());
     } catch (StopSignal $ex) {
         Logger::debug('received stop signal');
         throw $ex;
     } catch (\Exception $ex) {
         Logger::err($ex);
         \usleep(self::SLEEP_TIME_AFTER_ERROR);
     }
     if (!$target) {
         Logger::debug('fetched target is null. skipped');
         return;
     }
     try {
         $process = Process::fork($target);
         $this->_children[$process->getPid()] = new ProcessStub($process, $this->_config);
     } catch (\Exception $ex) {
         Logger::err('exception', array('exception' => $ex));
         \usleep(self::SLEEP_TIME_AFTER_ERROR);
     }
 }
Example #2
0
 public function testGetFactory_RunnableCallback()
 {
     $callback = function () {
         exit;
     };
     $data = array('worker' => $callback);
     $config = new Config($data);
     $factoryMethod = $config->getFactoryMethod();
     $this->assertTrue(\is_callable($factoryMethod));
     $callback1 = \call_user_func($factoryMethod);
     $this->assertEquals($callback, $callback1);
 }
Example #3
0
 protected function _startOne($groupId, Config $config)
 {
     $target = \call_user_func($config->getFactoryMethod());
     $process = Process::fork($target);
     $this->_children[$process->getPid()] = new ProcessStub($process, $config, $groupId);
 }