Skip to content

Commit f373c0a

Browse files
authored
Merge pull request #914 from uro/feature/async-command-extensions
async_commands: extended configuration proposal
2 parents add744c + fc9defb commit f373c0a

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

DependencyInjection/Configuration.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ private function getAsyncCommandsConfiguration(): ArrayNodeDefinition
7676
}
7777

7878
return (new ArrayNodeDefinition('async_commands'))
79+
->children()
80+
->booleanNode('enabled')->defaultFalse()->end()
81+
->integerNode('timeout')->min(0)->defaultValue(60)->end()
82+
->scalarNode('command_name')->defaultNull()->end()
83+
->scalarNode('queue_name')->defaultNull()->end()
84+
->end()
7985
->addDefaultsIfNotSet()
8086
->canBeEnabled()
8187
;

DependencyInjection/EnqueueExtension.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,19 @@ private function loadReplyExtension(array $config, ContainerBuilder $container):
363363

364364
private function loadAsyncCommands(array $config, ContainerBuilder $container): void
365365
{
366-
$configNames = [];
366+
$configs = [];
367367
foreach ($config as $name => $modules) {
368368
if (false === empty($modules['async_commands']['enabled'])) {
369-
$configNames[] = $name;
369+
$configs[] = [
370+
'name' => $name,
371+
'timeout' => $modules['async_commands']['timeout'],
372+
'command_name' => $modules['async_commands']['command_name'],
373+
'queue_name' => $modules['async_commands']['queue_name'],
374+
];
370375
}
371376
}
372377

373-
if (false == $configNames) {
378+
if (false == $configs) {
374379
return;
375380
}
376381

@@ -379,7 +384,7 @@ private function loadAsyncCommands(array $config, ContainerBuilder $container):
379384
}
380385

381386
$extension = new AsyncCommandExtension();
382-
$extension->load(['clients' => $configNames], $container);
387+
$extension->load(['clients' => $configs], $container);
383388
}
384389

385390
private function loadMessageQueueCollector(array $config, ContainerBuilder $container)

Tests/Functional/App/config/config.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ enqueue:
2828
traceable_producer: true
2929
job: true
3030
async_events: true
31-
async_commands: true
31+
async_commands:
32+
enabled: true
33+
timeout: 60
34+
command_name: ~
35+
queue_name: ~
3236

3337
services:
3438
test_enqueue.client.default.traceable_producer:
@@ -122,4 +126,4 @@ services:
122126
enqueue.events.async_listener:
123127
class: 'Enqueue\Bundle\Tests\Functional\App\AsyncListener'
124128
public: true
125-
arguments: ['@enqueue.client.default.producer', '@enqueue.events.registry']
129+
arguments: ['@enqueue.client.default.producer', '@enqueue.events.registry']

0 commit comments

Comments
 (0)