diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f26aa..5f0034a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Queue Client Bundle Changelog +## v1.1.0 + +- Handle symfony >= 3.3 + ## v1.0.3 - Change from error to warning when try to add alias on unknown queue diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2a1f78e..ae35a67 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -38,6 +38,9 @@ public function getConfigTreeBuilder() ->scalarNode('queues_file') ->defaultValue(__DIR__.'/../Resources/config/queues.yml') ->end() + ->scalarNode('queue_prefix') + ->defaultValue('') + ->end() ->scalarNode('priority_handler') ->defaultValue('ReputationVIP\QueueClient\PriorityHandler\StandardPriorityHandler') ->end() diff --git a/DependencyInjection/QueueClientExtension.php b/DependencyInjection/QueueClientExtension.php index 820247c..c8d0f6f 100644 --- a/DependencyInjection/QueueClientExtension.php +++ b/DependencyInjection/QueueClientExtension.php @@ -11,12 +11,7 @@ class QueueClientExtension extends Extension { public function load(array $configs, ContainerBuilder $container) { - $adapterChoice = array( - 'sqs' => 'ReputationVIP\QueueClient\Adapter\SQSAdapter', - 'file' => 'ReputationVIP\QueueClient\Adapter\FileAdapter', - 'memory' => 'ReputationVIP\QueueClient\Adapter\MemoryAdapter', - 'null' => 'ReputationVIP\QueueClient\Adapter\NullAdapter' - ); + $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); @@ -24,11 +19,8 @@ public function load(array $configs, ContainerBuilder $container) $container, new FileLocator(__DIR__.'/../Resources/config') ); - $loader->load('services.yml'); - if (!isset($adapterChoice[$config['adapter']['type']])) { - throw new \InvalidArgumentException('Unknown handler type : ' . $config['adapter']['type']); - } + $loader->load('services.yml'); $container->setParameter( 'queue_client.adapter.priority_handler.class', @@ -39,8 +31,8 @@ public function load(array $configs, ContainerBuilder $container) $config['queues_file'] ); $container->setParameter( - 'queue_client.adapter.class', - $adapterChoice[$config['adapter']['type']] + 'queue_client.queue_prefix', + $config['queue_prefix'] ); $container->setParameter( 'queue_client.config', diff --git a/QueueClientAdapterFactory.php b/QueueClientAdapterFactory.php index 9397e37..fcb70bf 100644 --- a/QueueClientAdapterFactory.php +++ b/QueueClientAdapterFactory.php @@ -20,6 +20,7 @@ class QueueClientAdapterFactory public function get($config, $priorityHandler) { $adapter = null; + var_dump($config['type']); switch ($config['type']) { case 'null': $adapter = new NullAdapter(); @@ -40,6 +41,8 @@ public function get($config, $priorityHandler) { case 'memory': $adapter = new MemoryAdapter($priorityHandler); break; + default: + throw new \InvalidArgumentException('Unknown handler type : ' . $config['type']); } return $adapter; diff --git a/README.md b/README.md index e515c50..974c6c9 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ queue_client: ### General configuration - ```queues_file``` specifies the default [queues configuration file](doc/queues-configuration-file.md). +- ```queue_prefix``` specifies a queue prefix can use in [queues configuration file](doc/queues-configuration-file.md). - ```priority_handler``` specifies the priority handler. Default is the `ReputationVIP\QueueClient\PriorityHandler\StandardPriorityHandler`. ### Available adapter types diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 354d445..da797d3 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -9,7 +9,7 @@ services: class: ReputationVIP\Bundle\QueueClientBundle\QueueClientFactory queue_client_adapter: - class: "%queue_client.adapter.class%" + class: ReputationVIP\QueueClient\Adapter\AbstractAdapter factory: ["@queue_client_adapter_factory", get] arguments: - "%queue_client.config%" diff --git a/doc/queues-configuration-file.md b/doc/queues-configuration-file.md index 024ab66..61bdf12 100644 --- a/doc/queues-configuration-file.md +++ b/doc/queues-configuration-file.md @@ -7,7 +7,7 @@ It requires a main node `queues` with one sub node for each queue. ## Sample -``` +```yaml queue_client: queues: queue1: @@ -16,7 +16,7 @@ queue_client: - queue1-alias1 - queue1-alias2 queue2: - name: queue2 + name: "%queue_client.queue_prefix%-queue2" aliases: - queue2-alias1 - queue2-alias2