diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f3d1eee2..c5feec75f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log +## [0.8.7](https://github.com/php-enqueue/enqueue-dev/tree/0.8.7) (2017-11-10) +[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.6...0.8.7) + +- \[Redis\] add custom database index [\#258](https://github.com/php-enqueue/enqueue-dev/pull/258) ([IndraGunawan](https://github.com/IndraGunawan)) + +- SetRouterPropertiesExtension does not work with SQS [\#261](https://github.com/php-enqueue/enqueue-dev/issues/261) + +- Changes SetRouterPropertiesExtension to use the driver to generate the queue name [\#262](https://github.com/php-enqueue/enqueue-dev/pull/262) ([iainmckay](https://github.com/iainmckay)) + ## [0.8.6](https://github.com/php-enqueue/enqueue-dev/tree/0.8.6) (2017-11-05) [Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.8.5...0.8.6) diff --git a/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php b/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php index 44b7ea493..d294a9d87 100644 --- a/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php +++ b/pkg/enqueue/Client/ConsumptionExtension/SetRouterPropertiesExtension.php @@ -36,7 +36,8 @@ public function onPreReceived(Context $context) } $config = $this->driver->getConfig(); - if ($context->getPsrQueue()->getQueueName() != $config->createTransportQueueName($config->getRouterQueueName())) { + $queue = $this->driver->createQueue($config->getRouterQueueName()); + if ($context->getPsrQueue()->getQueueName() != $queue->getQueueName()) { return; } diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php index d344ed60c..6dc723c37 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php @@ -30,6 +30,7 @@ public function testCouldBeConstructedWithRequiredArguments() public function testShouldSetRouterProcessorPropertyIfNotSetAndOnRouterQueue() { $config = Config::create('test', '', '', 'router-queue', '', 'router-processor-name'); + $queue = new NullQueue('test.router-queue'); $driver = $this->createDriverMock(); $driver @@ -38,6 +39,12 @@ public function testShouldSetRouterProcessorPropertyIfNotSetAndOnRouterQueue() ->willReturn($config) ; + $driver + ->expects($this->once()) + ->method('createQueue') + ->willReturn($queue) + ; + $message = new NullMessage(); $context = new Context($this->createPsrContextMock()); @@ -56,6 +63,7 @@ public function testShouldSetRouterProcessorPropertyIfNotSetAndOnRouterQueue() public function testShouldNotSetRouterProcessorPropertyIfNotSetAndNotOnRouterQueue() { $config = Config::create('test', '', '', 'router-queue', '', 'router-processor-name'); + $queue = new NullQueue('test.router-queue'); $driver = $this->createDriverMock(); $driver @@ -64,6 +72,12 @@ public function testShouldNotSetRouterProcessorPropertyIfNotSetAndNotOnRouterQue ->willReturn($config) ; + $driver + ->expects($this->once()) + ->method('createQueue') + ->willReturn($queue) + ; + $message = new NullMessage(); $context = new Context($this->createPsrContextMock()); diff --git a/pkg/redis/PhpRedis.php b/pkg/redis/PhpRedis.php index 139fa94dd..71ead40d4 100644 --- a/pkg/redis/PhpRedis.php +++ b/pkg/redis/PhpRedis.php @@ -26,6 +26,7 @@ public function __construct(array $config) 'reserved' => null, 'retry_interval' => null, 'persisted' => false, + 'database' => 0, ], $config); } @@ -80,6 +81,8 @@ public function connect() $this->config['retry_interval'] ); } + + $this->redis->select($this->config['database']); } return $this->redis; diff --git a/pkg/redis/RedisConnectionFactory.php b/pkg/redis/RedisConnectionFactory.php index 122bf0bef..021a448f4 100644 --- a/pkg/redis/RedisConnectionFactory.php +++ b/pkg/redis/RedisConnectionFactory.php @@ -27,6 +27,7 @@ class RedisConnectionFactory implements PsrConnectionFactory * 'vendor' => 'The library used internally to interact with Redis server * 'persisted' => bool, Whether it use single persisted connection or open a new one for every context * 'lazy' => the connection will be performed as later as possible, if the option set to true + * 'database' => Database index to select when connected (default value: 0) * ]. * * or @@ -139,6 +140,7 @@ private function defaultConfig() 'vendor' => 'phpredis', 'persisted' => false, 'lazy' => true, + 'database' => 0, ]; } } diff --git a/pkg/redis/Symfony/RedisTransportFactory.php b/pkg/redis/Symfony/RedisTransportFactory.php index 092e3baf8..f24df84e4 100644 --- a/pkg/redis/Symfony/RedisTransportFactory.php +++ b/pkg/redis/Symfony/RedisTransportFactory.php @@ -54,6 +54,10 @@ public function addConfiguration(ArrayNodeDefinition $builder) ->defaultTrue() ->info('the connection will be performed as later as possible, if the option set to true') ->end() + ->integerNode('database') + ->defaultValue(0) + ->info('Database index to select when connected.') + ->end() ; } diff --git a/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php b/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php index f3375e0de..51c185b9b 100644 --- a/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php +++ b/pkg/redis/Tests/RedisConnectionFactoryConfigTest.php @@ -71,6 +71,7 @@ public static function provideConfigs() 'vendor' => 'phpredis', 'persisted' => false, 'lazy' => true, + 'database' => 0, ], ]; @@ -85,6 +86,7 @@ public static function provideConfigs() 'vendor' => 'phpredis', 'persisted' => false, 'lazy' => true, + 'database' => 0, ], ]; @@ -99,6 +101,7 @@ public static function provideConfigs() 'vendor' => 'phpredis', 'persisted' => false, 'lazy' => true, + 'database' => 0, ], ]; @@ -114,6 +117,7 @@ public static function provideConfigs() 'persisted' => true, 'lazy' => false, 'foo' => 'bar', + 'database' => 0, ], ]; @@ -129,6 +133,7 @@ public static function provideConfigs() 'persisted' => false, 'lazy' => true, 'foo' => 'bar', + 'database' => 0, ], ]; } diff --git a/pkg/redis/Tests/Symfony/RedisTransportFactoryTest.php b/pkg/redis/Tests/Symfony/RedisTransportFactoryTest.php index 1b4175e6a..ca7d402c8 100644 --- a/pkg/redis/Tests/Symfony/RedisTransportFactoryTest.php +++ b/pkg/redis/Tests/Symfony/RedisTransportFactoryTest.php @@ -58,6 +58,7 @@ public function testShouldAllowAddConfiguration() 'vendor' => 'phpredis', 'persisted' => true, 'lazy' => false, + 'database' => 0, ], $config); }