Skip to content

Commit 34aff09

Browse files
committed
Require providers to specify a driver and simplify config parsing accordingly
1 parent 601d34e commit 34aff09

4 files changed

Lines changed: 9 additions & 24 deletions

File tree

docs/sync-provider.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ of queue-based code paths.
88
Configuration
99
^^^^^^^^^^^^^
1010

11-
To use the sync queue, set the ``provider`` of a given queue to ``sync``. No further
11+
To designate a queue as synchronous, set the ``driver`` of its provider to ``sync``. No further
1212
configuration is necessary.
1313

1414
.. code-block:: yaml
1515
1616
#app/config_dev.yml
1717
1818
uecode_qpush:
19+
providers:
20+
in_band:
21+
driver: sync
1922
queues:
2023
my_queue_name:
21-
provider: sync
24+
provider: in_band

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,12 @@ private function getProvidersNode()
6363
];
6464

6565
$node
66-
->beforeNormalization()
67-
->always(function (array $providers) use ($requirements) {
68-
array_walk(
69-
$providers,
70-
function (&$provider, $name) use ($requirements) {
71-
if (
72-
empty($provider['driver']) &&
73-
array_key_exists($name, $requirements)
74-
) {
75-
$provider['driver'] = $name;
76-
}
77-
}
78-
);
79-
80-
return $providers;
81-
})
82-
->end()
8366
->useAttributeAsKey('name')
8467
->prototype('array')
8568
->treatNullLike([])
8669
->children()
8770
->enumNode('driver')
71+
->isRequired()
8872
->values(array_keys($requirements))
8973
->end()
9074
// IronMQ

src/DependencyInjection/UecodeQPushExtension.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ public function load(array $configs, ContainerBuilder $container)
6060
$class = null;
6161
$client = null;
6262

63-
$driver = isset($config['providers'][$provider]['driver']) ?
64-
$config['providers'][$provider]['driver']
65-
: $provider;
66-
67-
switch ($driver) {
63+
switch ($config['providers'][$provider]['driver']) {
6864
case 'aws':
6965
$class = $container->getParameter('uecode_qpush.provider.aws');
7066
$client = $this->createAwsClient(

tests/Fixtures/config_test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ uecode_qpush:
33
logging_enabled: true
44
providers:
55
aws:
6+
driver: aws
67
key: 123
78
secret: 123
89
region: us-east-1
@@ -12,6 +13,7 @@ uecode_qpush:
1213
secret: 432
1314
region: eu-west-1
1415
ironmq:
16+
driver: ironmq
1517
token: 123
1618
project_id: 123
1719
secondary_ironmq:

0 commit comments

Comments
 (0)