Example #1
0
 /**
  * @covers Gloubster\Worker\Factory::createWorker
  */
 public function testCreateImageWorker()
 {
     $configuration = new Configuration(json_encode(array("server" => array("host" => "localhost", "port" => 5672, "user" => "guest", "password" => "guest", "vhost" => "/"), "workers" => array("image" => array("queue-name" => 'Gloubster\\Configuration::QUEUE_IMAGE_PROCESSING')))), array(file_get_contents(__DIR__ . '/../../../../../resources/configuration.schema.json')));
     $filesystem = $this->getMockBuilder('Neutron\\TemporaryFilesystem\\TemporaryFilesystem')->disableOriginalConstructor()->getmock();
     $logger = $this->getMockBuilder('Monolog\\Logger')->disableOriginalConstructor()->getmock();
     $worker = Factory::createWorker("image", "image-001", $this->getConnection(), $configuration, $filesystem, $logger);
     $this->assertInstanceOf('Gloubster\\Worker\\ImageWorker', $worker);
 }
Example #2
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $conn = AMQPFactory::createAMQPLibConnection($this->conf);
     $type = $input->getArgument('type');
     $id = $input->getArgument('id') ?: $this->generateId($type);
     $output->writeln(sprintf("Running %s worker #%s ...", $type, $id));
     $worker = Factory::createWorker($type, $id, $conn, $this->conf, new TemporaryFilesystem(), $this->logger);
     if (0 < (int) $input->getOption('timeout')) {
         $worker->setTimeout($input->getOption('timeout'));
     }
     $worker->run($input->getOption('iterations'));
 }