Exemplo n.º 1
0
 /**
  * check $configuration, get client related to connection config, create vhost, then process exchange and queue
  * @param $vhostName
  * @param array $configuration
  */
 public function processVhost($vhostName, array $configuration)
 {
     $client = $this->clientPool->getClientByName($configuration['connection']);
     $vhostName = urlencode($vhostName);
     $client->query(ClientInterface::METHOD_PUT, sprintf('/api/vhosts/%s', $vhostName), []);
     $this->logger->info(sprintf('Create vhost: <info>%s</info>', urldecode($vhostName)));
     //process parameters
     if (isset($configuration['parameters']) && count($configuration['parameters'])) {
         $this->parameterManager->setClient($client)->setVhost($vhostName);
         foreach ($configuration['parameters'] as $paramType => $parameters) {
             foreach ($parameters as $paramName => $paramOptions) {
                 $this->parameterManager->create($paramType, $paramName, $paramOptions);
             }
         }
     }
     //process exchanges
     if (isset($configuration['exchanges']) && count($configuration['exchanges'])) {
         $this->process($this->exchangeManager, $client, $vhostName, $configuration['exchanges']);
     }
     //process queues
     if (isset($configuration['queues']) && count($configuration['queues'])) {
         $this->process($this->queueManager, $client, $vhostName, $configuration['queues']);
     }
     //process policies
     if (isset($configuration['policies']) && count($configuration['policies'])) {
         $this->process($this->policyManager, $client, $vhostName, $configuration['policies']);
     }
 }
Exemplo n.º 2
0
 /**
  * Check config with option resolver.
  * Apply each vhost config with VhostManager
  *
  * @param array $config
  */
 public function manageConfig(array $config)
 {
     $this->clientPool->setConnections($config['connections']);
     foreach ($config['vhosts'] as $name => $vhostConfig) {
         $this->vhostManager->processVhost($name, $vhostConfig);
     }
 }
Exemplo n.º 3
0
 public function testClient()
 {
     $pool = new ClientPool($this->factory);
     $this->factory->expects($this->once())->method('createClient')->with(['info'])->willReturn('client1');
     $pool->setConnections(['ulrich' => ['info']]);
     $client1 = $pool->getClientByName('ulrich');
     $this->assertEquals($client1, $pool->getClientByName('ulrich'));
 }