Skip to content

Commit 16a5218

Browse files
committed
multi client configuration
1 parent 1db3a2e commit 16a5218

40 files changed

+255
-328
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"ext-mongodb": "^1.3",
1212
"ext-rdkafka": "^3.0.3",
1313

14-
"queue-interop/amqp-interop": "0.8.x-dev",
15-
"queue-interop/queue-interop": "0.7.x-dev",
14+
"queue-interop/amqp-interop": "^0.8",
15+
"queue-interop/queue-interop": "^0.7",
1616
"bunny/bunny": "^0.2.4|^0.3|^0.4",
1717
"php-amqplib/php-amqplib": "^2.7",
1818
"doctrine/dbal": "~2.5",
@@ -38,7 +38,7 @@
3838
"require-dev": {
3939
"phpunit/phpunit": "^5.5",
4040
"phpstan/phpstan": "^0.10",
41-
"queue-interop/queue-spec": "0.6.x-dev",
41+
"queue-interop/queue-spec": "^0.6",
4242
"symfony/browser-kit": "4.0.*",
4343
"symfony/config": "4.0.*",
4444
"symfony/process": "4.0.*",

pkg/amqp-bunny/composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"license": "MIT",
88
"require": {
99
"php": "^7.1.3",
10-
"queue-interop/amqp-interop": "0.8.x-dev",
11-
"queue-interop/queue-interop": "0.7.x-dev",
10+
"queue-interop/amqp-interop": "^0.8",
11+
"queue-interop/queue-interop": "^0.7",
1212
"bunny/bunny": "^0.2.4|^0.3|^0.4",
1313
"enqueue/amqp-tools": "0.9.x-dev"
1414
},
1515
"require-dev": {
1616
"phpunit/phpunit": "~5.4.0",
1717
"enqueue/test": "0.9.x-dev",
1818
"enqueue/null": "0.9.x-dev",
19-
"queue-interop/queue-spec": "0.6.x-dev"
19+
"queue-interop/queue-spec": "^0.6"
2020
},
2121
"support": {
2222
"email": "[email protected]",

pkg/amqp-ext/composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
"require": {
99
"php": "^7.1.3",
1010
"ext-amqp": "^1.9.3",
11-
"queue-interop/amqp-interop": "0.8.x-dev",
12-
"queue-interop/queue-interop": "0.7.x-dev",
11+
"queue-interop/amqp-interop": "^0.8",
12+
"queue-interop/queue-interop": "^0.7",
1313
"enqueue/amqp-tools": "0.9.x-dev"
1414
},
1515
"require-dev": {
1616
"phpunit/phpunit": "~5.4.0",
1717
"enqueue/test": "0.9.x-dev",
1818
"enqueue/null": "0.9.x-dev",
19-
"queue-interop/queue-spec": "0.6.x-dev",
19+
"queue-interop/queue-spec": "^0.6",
2020
"empi89/php-amqp-stubs": "*@dev"
2121
},
2222
"support": {

pkg/amqp-lib/composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
"require": {
99
"php": "^7.1.3",
1010
"php-amqplib/php-amqplib": "^2.7",
11-
"queue-interop/amqp-interop": "0.8.x-dev",
11+
"queue-interop/amqp-interop": "^0.8",
1212
"enqueue/amqp-tools": "0.9.x-dev"
1313
},
1414
"require-dev": {
1515
"phpunit/phpunit": "~5.4.0",
1616
"enqueue/test": "0.9.x-dev",
1717
"enqueue/null": "0.9.x-dev",
18-
"queue-interop/queue-spec": "0.6.x-dev"
18+
"queue-interop/queue-spec": "^0.6"
1919
},
2020
"support": {
2121
"email": "[email protected]",

pkg/amqp-tools/composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"license": "MIT",
88
"require": {
99
"php": "^7.1.3",
10-
"queue-interop/amqp-interop": "0.8.x-dev",
11-
"queue-interop/queue-interop": "0.7.x-dev"
10+
"queue-interop/amqp-interop": "^0.8",
11+
"queue-interop/queue-interop": "^0.7"
1212
},
1313
"require-dev": {
1414
"phpunit/phpunit": "~5.4.0",

pkg/async-command/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"require": {
99
"php": ">=7.1",
1010
"enqueue/enqueue": "0.9.x-dev",
11-
"queue-interop/queue-interop": "0.7.x-dev",
11+
"queue-interop/queue-interop": "^0.7",
1212
"symfony/console": "^3.4|^4",
1313
"symfony/process": "^3.4|^4"
1414
},

pkg/async-event-dispatcher/DependencyInjection/AsyncEventsPass.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public function process(ContainerBuilder $container): void
1919
return;
2020
}
2121

22+
$defaultClient = $container->getParameter('enqueue.default_client');
23+
2224
$registeredToEvent = [];
2325
foreach ($container->findTaggedServiceIds('kernel.event_listener') as $serviceId => $tagAttributes) {
2426
foreach ($tagAttributes as $tagAttribute) {
@@ -44,7 +46,7 @@ public function process(ContainerBuilder $container): void
4446
$container->getDefinition('enqueue.events.async_processor')
4547
->addTag('enqueue.processor', [
4648
'topic' => 'event.'.$event,
47-
'client' => 'default',
49+
'client' => $defaultClient,
4850
])
4951
;
5052

@@ -78,7 +80,7 @@ public function process(ContainerBuilder $container): void
7880
$container->getDefinition('enqueue.events.async_processor')
7981
->addTag('enqueue.processor', [
8082
'topicName' => 'event.'.$event,
81-
'client' => 'default',
83+
'client' => $defaultClient,
8284
])
8385
;
8486

pkg/async-event-dispatcher/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"require": {
99
"php": "^7.1.3",
1010
"enqueue/enqueue": "0.9.x-dev",
11-
"queue-interop/queue-interop": "0.7.x-dev",
11+
"queue-interop/queue-interop": "^0.7",
1212
"symfony/event-dispatcher": "^3.4|^4"
1313
},
1414
"require-dev": {

pkg/dbal/composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"license": "MIT",
88
"require": {
99
"php": "^7.1.3",
10-
"queue-interop/queue-interop": "0.7.x-dev",
10+
"queue-interop/queue-interop": "^0.7",
1111
"doctrine/dbal": "~2.5",
1212
"ramsey/uuid": "^3"
1313
},
1414
"require-dev": {
1515
"phpunit/phpunit": "~5.4.0",
1616
"enqueue/test": "0.9.x-dev",
1717
"enqueue/null": "0.9.x-dev",
18-
"queue-interop/queue-spec": "0.6.x-dev"
18+
"queue-interop/queue-spec": "^0.6"
1919
},
2020
"support": {
2121
"email": "[email protected]",

pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function load(array $configs, ContainerBuilder $container): void
4343
}
4444

4545
// or with name 'default'
46-
if ('default' === $name) {
46+
if (DiUtils::DEFAULT_CONFIG === $name) {
4747
$defaultName = $name;
4848
}
4949
}

pkg/enqueue-bundle/composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"require": {
99
"php": "^7.1.3",
1010
"symfony/framework-bundle": "^3.4|^4",
11-
"queue-interop/amqp-interop": "0.8.x-dev",
12-
"queue-interop/queue-interop": "0.7.x-dev",
11+
"queue-interop/amqp-interop": "^0.8",
12+
"queue-interop/queue-interop": "^0.7",
1313
"enqueue/enqueue": "0.9.x-dev",
1414
"enqueue/null": "0.9.x-dev"
1515
},

pkg/enqueue/Symfony/Client/DependencyInjection/AnalyzeRouteCollectionPass.php

+4-11
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
namespace Enqueue\Symfony\Client\DependencyInjection;
44

55
use Enqueue\Client\RouteCollection;
6+
use Enqueue\Symfony\DiUtils;
67
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
78
use Symfony\Component\DependencyInjection\ContainerBuilder;
89

910
final class AnalyzeRouteCollectionPass implements CompilerPassInterface
1011
{
11-
use FormatClientNameTrait;
12-
13-
protected $name;
14-
1512
public function process(ContainerBuilder $container): void
1613
{
1714
if (false == $container->hasParameter('enqueue.clients')) {
@@ -21,8 +18,9 @@ public function process(ContainerBuilder $container): void
2118
$names = $container->getParameter('enqueue.clients');
2219

2320
foreach ($names as $name) {
24-
$this->name = $name;
25-
$routeCollectionId = $this->format('route_collection');
21+
$diUtils = DiUtils::create(ClientFactory::MODULE, $name);
22+
23+
$routeCollectionId = $diUtils->format('route_collection');
2624
if (false == $container->hasDefinition($routeCollectionId)) {
2725
throw new \LogicException(sprintf('Service "%s" not found', $routeCollectionId));
2826
}
@@ -36,11 +34,6 @@ public function process(ContainerBuilder $container): void
3634
}
3735
}
3836

39-
protected function getName(): string
40-
{
41-
return $this->name;
42-
}
43-
4437
private function exclusiveCommandsCouldNotBeRunOnDefaultQueue(RouteCollection $collection): void
4538
{
4639
foreach ($collection->all() as $route) {

pkg/enqueue/Symfony/Client/DependencyInjection/BuildClientExtensionsPass.php

+7-13
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@
22

33
namespace Enqueue\Symfony\Client\DependencyInjection;
44

5+
use Enqueue\Symfony\DiUtils;
56
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
67
use Symfony\Component\DependencyInjection\ContainerBuilder;
78
use Symfony\Component\DependencyInjection\Reference;
89

910
final class BuildClientExtensionsPass implements CompilerPassInterface
1011
{
11-
use FormatClientNameTrait;
12-
13-
protected $name;
14-
1512
public function process(ContainerBuilder $container): void
1613
{
1714
if (false == $container->hasParameter('enqueue.clients')) {
1815
throw new \LogicException('The "enqueue.clients" parameter must be set.');
1916
}
2017

2118
$names = $container->getParameter('enqueue.clients');
19+
$defaultName = $container->getParameter('enqueue.default_client');
2220

2321
foreach ($names as $name) {
24-
$this->name = $name;
25-
$extensionsId = $this->format('client_extensions');
22+
$diUtils = DiUtils::create(ClientFactory::MODULE, $name);
23+
24+
$extensionsId = $diUtils->format('client_extensions');
2625
if (false == $container->hasDefinition($extensionsId)) {
2726
throw new \LogicException(sprintf('Service "%s" not found', $extensionsId));
2827
}
@@ -35,9 +34,9 @@ public function process(ContainerBuilder $container): void
3534
$groupByPriority = [];
3635
foreach ($tags as $serviceId => $tagAttributes) {
3736
foreach ($tagAttributes as $tagAttribute) {
38-
$client = $tagAttribute['client'] ?? 'default';
37+
$client = $tagAttribute['client'] ?? $defaultName;
3938

40-
if ($client !== $this->name && 'all' !== $client) {
39+
if ($client !== $name && 'all' !== $client) {
4140
continue;
4241
}
4342

@@ -61,9 +60,4 @@ public function process(ContainerBuilder $container): void
6160
));
6261
}
6362
}
64-
65-
protected function getName(): string
66-
{
67-
return $this->name;
68-
}
6963
}

pkg/enqueue/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPass.php

+6-13
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,24 @@
55
use Enqueue\Client\CommandSubscriberInterface;
66
use Enqueue\Client\Route;
77
use Enqueue\Client\RouteCollection;
8+
use Enqueue\Symfony\DiUtils;
89
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
910
use Symfony\Component\DependencyInjection\ContainerBuilder;
1011

1112
final class BuildCommandSubscriberRoutesPass implements CompilerPassInterface
1213
{
13-
use FormatClientNameTrait;
14-
15-
protected $name;
16-
1714
public function process(ContainerBuilder $container): void
1815
{
1916
if (false == $container->hasParameter('enqueue.clients')) {
2017
throw new \LogicException('The "enqueue.clients" parameter must be set.');
2118
}
2219

2320
$names = $container->getParameter('enqueue.clients');
21+
$defaultName = $container->getParameter('enqueue.default_client');
2422

2523
foreach ($names as $name) {
26-
$this->name = $name;
27-
$routeCollectionId = sprintf('enqueue.client.%s.route_collection', $this->name);
24+
$diUtils = DiUtils::create(ClientFactory::MODULE, $name);
25+
$routeCollectionId = $diUtils->format('route_collection');
2826
if (false == $container->hasDefinition($routeCollectionId)) {
2927
throw new \LogicException(sprintf('Service "%s" not found', $routeCollectionId));
3028
}
@@ -47,9 +45,9 @@ public function process(ContainerBuilder $container): void
4745
}
4846

4947
foreach ($tagAttributes as $tagAttribute) {
50-
$client = $tagAttribute['client'] ?? 'default';
48+
$client = $tagAttribute['client'] ?? $defaultName;
5149

52-
if ($client !== $this->name && 'all' !== $client) {
50+
if ($client !== $name && 'all' !== $client) {
5351
continue;
5452
}
5553

@@ -103,9 +101,4 @@ public function process(ContainerBuilder $container): void
103101
));
104102
}
105103
}
106-
107-
protected function getName(): string
108-
{
109-
return $this->name;
110-
}
111104
}

pkg/enqueue/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPass.php

+6-13
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,26 @@
22

33
namespace Enqueue\Symfony\Client\DependencyInjection;
44

5+
use Enqueue\Symfony\DiUtils;
56
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
67
use Symfony\Component\DependencyInjection\ContainerBuilder;
78
use Symfony\Component\DependencyInjection\Reference;
89

910
final class BuildConsumptionExtensionsPass implements CompilerPassInterface
1011
{
11-
use FormatClientNameTrait;
12-
13-
protected $name;
14-
1512
public function process(ContainerBuilder $container): void
1613
{
1714
if (false == $container->hasParameter('enqueue.clients')) {
1815
throw new \LogicException('The "enqueue.clients" parameter must be set.');
1916
}
2017

2118
$names = $container->getParameter('enqueue.clients');
19+
$defaultName = $container->getParameter('enqueue.default_client');
2220

2321
foreach ($names as $name) {
24-
$this->name = $name;
22+
$diUtils = DiUtils::create(ClientFactory::MODULE, $name);
2523

26-
$extensionsId = $this->format('consumption_extensions');
24+
$extensionsId = $diUtils->format('consumption_extensions');
2725
if (false == $container->hasDefinition($extensionsId)) {
2826
throw new \LogicException(sprintf('Service "%s" not found', $extensionsId));
2927
}
@@ -36,9 +34,9 @@ public function process(ContainerBuilder $container): void
3634
$groupByPriority = [];
3735
foreach ($tags as $serviceId => $tagAttributes) {
3836
foreach ($tagAttributes as $tagAttribute) {
39-
$client = $tagAttribute['client'] ?? 'default';
37+
$client = $tagAttribute['client'] ?? $defaultName;
4038

41-
if ($client !== $this->name && 'all' !== $client) {
39+
if ($client !== $name && 'all' !== $client) {
4240
continue;
4341
}
4442

@@ -62,9 +60,4 @@ public function process(ContainerBuilder $container): void
6260
));
6361
}
6462
}
65-
66-
protected function getName(): string
67-
{
68-
return $this->name;
69-
}
7063
}

0 commit comments

Comments
 (0)