Skip to content

Commit dbf168e

Browse files
committed
Merge branch 'master' into gps
2 parents ef55be6 + 29b30ab commit dbf168e

28 files changed

+309
-70
lines changed

.travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,12 @@ script:
5151
- if [ "$PHP_CS_FIXER" = true ]; then ./bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}"; fi
5252
- if [ "$UNIT_TESTS" = true ]; then bin/phpunit --exclude-group=functional; fi
5353
- if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -t; fi
54+
55+
notifications:
56+
webhooks:
57+
urls:
58+
- https://webhooks.gitter.im/e/3f8b3668e7792de23a49
59+
on_success: change
60+
on_failure: always
61+
on_start: never
5462

CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Change Log
22

3+
## [0.7.7](https://github.com/php-enqueue/enqueue-dev/tree/0.7.7) (2017-08-25)
4+
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.7.6...0.7.7)
5+
6+
- Add support for Google Cloud Pub/Sub [\#83](https://github.com/php-enqueue/enqueue-dev/issues/83)
7+
8+
- Use Query Builder for better support across platforms. [\#176](https://github.com/php-enqueue/enqueue-dev/pull/176) ([jenkoian](https://github.com/jenkoian))
9+
- fix pheanstalk redelivered, receive [\#173](https://github.com/php-enqueue/enqueue-dev/pull/173) ([ASKozienko](https://github.com/ASKozienko))
10+
11+
## [0.7.6](https://github.com/php-enqueue/enqueue-dev/tree/0.7.6) (2017-08-16)
12+
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.7.5...0.7.6)
13+
14+
## [0.7.5](https://github.com/php-enqueue/enqueue-dev/tree/0.7.5) (2017-08-16)
15+
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.7.4...0.7.5)
16+
17+
- Bundle disable async events by default [\#169](https://github.com/php-enqueue/enqueue-dev/pull/169) ([makasim](https://github.com/makasim))
18+
- Delay Strategy Configuration [\#162](https://github.com/php-enqueue/enqueue-dev/pull/162) ([ASKozienko](https://github.com/ASKozienko))
19+
20+
## [0.7.4](https://github.com/php-enqueue/enqueue-dev/tree/0.7.4) (2017-08-10)
21+
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.7.3...0.7.4)
22+
323
## [0.7.3](https://github.com/php-enqueue/enqueue-dev/tree/0.7.3) (2017-08-09)
424
[Full Changelog](https://github.com/php-enqueue/enqueue-dev/compare/0.7.2...0.7.3)
525

pkg/amqp-bunny/composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
"queue-interop/amqp-interop": "^0.6@dev",
1111
"bunny/bunny": "^0.2.4",
12-
"enqueue/amqp-tools": "^0.7@dev",
13-
"psr/log": "^1"
12+
"enqueue/amqp-tools": "^0.7@dev"
1413
},
1514
"require-dev": {
1615
"phpunit/phpunit": "~5.4.0",

pkg/amqp-ext/composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"ext-amqp": "^1.6",
1010

1111
"queue-interop/amqp-interop": "^0.6@dev",
12-
"enqueue/amqp-tools": "^0.7@dev",
13-
"psr/log": "^1"
12+
"enqueue/amqp-tools": "^0.7@dev"
1413
},
1514
"require-dev": {
1615
"phpunit/phpunit": "~5.4.0",

pkg/amqp-lib/composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"php-amqplib/php-amqplib": "^2.7@dev",
1010
"queue-interop/queue-interop": "^0.6@dev",
1111
"queue-interop/amqp-interop": "^0.6@dev",
12-
"enqueue/amqp-tools": "^0.7@dev",
13-
"psr/log": "^1"
12+
"enqueue/amqp-tools": "^0.7@dev"
1413
},
1514
"require-dev": {
1615
"phpunit/phpunit": "~5.4.0",

pkg/dbal/DbalConsumer.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ protected function receiveMessage()
169169
try {
170170
$now = time();
171171

172-
$sql = sprintf(
173-
'SELECT * FROM %s WHERE queue=:queue AND '.
174-
'(delayed_until IS NULL OR delayed_until<=:delayedUntil) '.
175-
'ORDER BY priority DESC, id ASC LIMIT 1 FOR UPDATE',
176-
$this->context->getTableName()
177-
);
172+
$query = $this->dbal->createQueryBuilder();
173+
$query
174+
->select('*')
175+
->from($this->context->getTableName())
176+
->where('queue = :queue')
177+
->andWhere('(delayed_until IS NULL OR delayed_until <= :delayedUntil)')
178+
->orderBy('priority', 'desc')
179+
->orderBy('id', 'asc')
180+
->setMaxResults(1)
181+
;
182+
183+
$sql = $query->getSQL().' '.$this->dbal->getDatabasePlatform()->getWriteLockSQL();
178184

179185
$dbalMessage = $this->dbal->executeQuery(
180186
$sql,

pkg/dbal/Tests/DbalConsumerTest.php

+135
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Enqueue\Dbal\Tests;
44

55
use Doctrine\DBAL\Connection;
6+
use Doctrine\DBAL\Platforms\AbstractPlatform;
7+
use Doctrine\DBAL\Query\QueryBuilder;
68
use Doctrine\DBAL\Statement;
79
use Enqueue\Dbal\DbalConsumer;
810
use Enqueue\Dbal\DbalContext;
@@ -148,7 +150,41 @@ public function testShouldReceiveMessage()
148150
->will($this->returnValue($dbalMessage))
149151
;
150152

153+
$queryBuilder = $this->createQueryBuilderMock();
154+
$queryBuilder
155+
->expects($this->once())
156+
->method('select')
157+
->will($this->returnSelf())
158+
;
159+
$queryBuilder
160+
->expects($this->once())
161+
->method('from')
162+
->will($this->returnSelf())
163+
;
164+
$queryBuilder
165+
->expects($this->once())
166+
->method('where')
167+
->will($this->returnSelf())
168+
;
169+
$queryBuilder
170+
->expects($this->once())
171+
->method('andWhere')
172+
->will($this->returnSelf())
173+
;
174+
$queryBuilder
175+
->expects($this->exactly(2))
176+
->method('orderBy')
177+
->will($this->returnSelf())
178+
;
179+
180+
$platform = $this->createPlatformMock();
181+
151182
$dbal = $this->createConnectionMock();
183+
$dbal
184+
->expects($this->once())
185+
->method('createQueryBuilder')
186+
->willReturn($queryBuilder)
187+
;
152188
$dbal
153189
->expects($this->once())
154190
->method('executeQuery')
@@ -163,6 +199,11 @@ public function testShouldReceiveMessage()
163199
->expects($this->once())
164200
->method('commit')
165201
;
202+
$dbal
203+
->expects($this->once())
204+
->method('getDatabasePlatform')
205+
->willReturn($platform)
206+
;
166207

167208
$context = $this->createContextMock();
168209
$context
@@ -201,7 +242,41 @@ public function testShouldReturnNullIfThereIsNoNewMessage()
201242
->will($this->returnValue(null))
202243
;
203244

245+
$queryBuilder = $this->createQueryBuilderMock();
246+
$queryBuilder
247+
->expects($this->once())
248+
->method('select')
249+
->will($this->returnSelf())
250+
;
251+
$queryBuilder
252+
->expects($this->once())
253+
->method('from')
254+
->will($this->returnSelf())
255+
;
256+
$queryBuilder
257+
->expects($this->once())
258+
->method('where')
259+
->will($this->returnSelf())
260+
;
261+
$queryBuilder
262+
->expects($this->once())
263+
->method('andWhere')
264+
->will($this->returnSelf())
265+
;
266+
$queryBuilder
267+
->expects($this->exactly(2))
268+
->method('orderBy')
269+
->will($this->returnSelf())
270+
;
271+
272+
$platform = $this->createPlatformMock();
273+
204274
$dbal = $this->createConnectionMock();
275+
$dbal
276+
->expects($this->once())
277+
->method('createQueryBuilder')
278+
->willReturn($queryBuilder)
279+
;
205280
$dbal
206281
->expects($this->once())
207282
->method('executeQuery')
@@ -216,6 +291,11 @@ public function testShouldReturnNullIfThereIsNoNewMessage()
216291
->expects($this->once())
217292
->method('commit')
218293
;
294+
$dbal
295+
->expects($this->once())
296+
->method('getDatabasePlatform')
297+
->willReturn($platform)
298+
;
219299

220300
$context = $this->createContextMock();
221301
$context
@@ -250,7 +330,41 @@ public function testShouldThrowIfMessageWasNotRemoved()
250330
->will($this->returnValue(['id' => '2134']))
251331
;
252332

333+
$queryBuilder = $this->createQueryBuilderMock();
334+
$queryBuilder
335+
->expects($this->once())
336+
->method('select')
337+
->will($this->returnSelf())
338+
;
339+
$queryBuilder
340+
->expects($this->once())
341+
->method('from')
342+
->will($this->returnSelf())
343+
;
344+
$queryBuilder
345+
->expects($this->once())
346+
->method('where')
347+
->will($this->returnSelf())
348+
;
349+
$queryBuilder
350+
->expects($this->once())
351+
->method('andWhere')
352+
->will($this->returnSelf())
353+
;
354+
$queryBuilder
355+
->expects($this->exactly(2))
356+
->method('orderBy')
357+
->will($this->returnSelf())
358+
;
359+
360+
$platform = $this->createPlatformMock();
361+
253362
$dbal = $this->createConnectionMock();
363+
$dbal
364+
->expects($this->once())
365+
->method('createQueryBuilder')
366+
->willReturn($queryBuilder)
367+
;
254368
$dbal
255369
->expects($this->once())
256370
->method('executeQuery')
@@ -269,6 +383,11 @@ public function testShouldThrowIfMessageWasNotRemoved()
269383
->expects($this->once())
270384
->method('rollBack')
271385
;
386+
$dbal
387+
->expects($this->once())
388+
->method('getDatabasePlatform')
389+
->willReturn($platform)
390+
;
272391

273392
$context = $this->createContextMock();
274393
$context
@@ -318,6 +437,22 @@ private function createContextMock()
318437
{
319438
return $this->createMock(DbalContext::class);
320439
}
440+
441+
/**
442+
* @return \PHPUnit_Framework_MockObject_MockObject|QueryBuilder
443+
*/
444+
private function createQueryBuilderMock()
445+
{
446+
return $this->createMock(QueryBuilder::class);
447+
}
448+
449+
/**
450+
* @return \PHPUnit_Framework_MockObject_MockObject|AbstractPlatform
451+
*/
452+
private function createPlatformMock()
453+
{
454+
return $this->createMock(AbstractPlatform::class);
455+
}
321456
}
322457

323458
class InvalidMessage implements PsrMessage

pkg/dbal/composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"require": {
88
"php": ">=5.6",
99
"queue-interop/queue-interop": "^0.6@dev",
10-
"doctrine/dbal": "~2.5",
11-
"psr/log": "^1"
10+
"doctrine/dbal": "~2.5"
1211
},
1312
"require-dev": {
1413
"phpunit/phpunit": "~5.4.0",

pkg/enqueue-bundle/DependencyInjection/Compiler/BuildTopicMetaSubscribersPass.php

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public function process(ContainerBuilder $container)
1616
{
1717
$processorTagName = 'enqueue.client.processor';
1818

19+
if (false == $container->hasDefinition('enqueue.client.meta.topic_meta_registry')) {
20+
return;
21+
}
22+
1923
$topicsSubscribers = [];
2024
foreach ($container->findTaggedServiceIds($processorTagName) as $serviceId => $tagAttributes) {
2125
$subscriptions = $this->extractSubscriptions($container, $serviceId, $tagAttributes);

pkg/enqueue-bundle/DependencyInjection/Configuration.php

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function getConfigTreeBuilder()
5252
->end()->end()
5353
->booleanNode('job')->defaultFalse()->end()
5454
->arrayNode('async_events')
55+
->addDefaultsIfNotSet()
5556
->canBeEnabled()
5657
->end()
5758
->arrayNode('extensions')->addDefaultsIfNotSet()->children()

pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function load(array $configs, ContainerBuilder $container)
118118
$loader->load('job.yml');
119119
}
120120

121-
if (isset($config['async_events']['enabled'])) {
121+
if ($config['async_events']['enabled']) {
122122
$extension = new AsyncEventDispatcherExtension();
123123
$extension->load([[
124124
'context_service' => 'enqueue.transport.default.context',

pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php

+47
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,51 @@ public function testReplyExtensionCouldBeDisabled()
376376
],
377377
], $config);
378378
}
379+
380+
public function testShouldDisableAsyncEventsByDefault()
381+
{
382+
$configuration = new Configuration([]);
383+
384+
$processor = new Processor();
385+
$config = $processor->processConfiguration($configuration, [[
386+
'transport' => [],
387+
]]);
388+
389+
$this->assertArraySubset([
390+
'async_events' => [
391+
'enabled' => false,
392+
],
393+
], $config);
394+
}
395+
396+
public function testShouldAllowEnableAsyncEvents()
397+
{
398+
$configuration = new Configuration([]);
399+
400+
$processor = new Processor();
401+
402+
$config = $processor->processConfiguration($configuration, [[
403+
'transport' => [],
404+
'async_events' => true,
405+
]]);
406+
407+
$this->assertArraySubset([
408+
'async_events' => [
409+
'enabled' => true,
410+
],
411+
], $config);
412+
413+
$config = $processor->processConfiguration($configuration, [[
414+
'transport' => [],
415+
'async_events' => [
416+
'enabled' => true,
417+
],
418+
]]);
419+
420+
$this->assertArraySubset([
421+
'async_events' => [
422+
'enabled' => true,
423+
],
424+
], $config);
425+
}
379426
}

pkg/enqueue/composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"php": ">=5.6",
99
"queue-interop/queue-interop": "^0.6@dev",
1010
"enqueue/null": "^0.7@dev",
11-
"ramsey/uuid": "^2|^3.5"
11+
"ramsey/uuid": "^2|^3.5",
12+
"psr/log": "^1"
1213
},
1314
"require-dev": {
1415
"phpunit/phpunit": "~5.5",

0 commit comments

Comments
 (0)