forked from php-enqueue/enqueue-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAsyncCommandExtension.php
More file actions
40 lines (36 loc) · 1.46 KB
/
AsyncCommandExtension.php
File metadata and controls
40 lines (36 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Enqueue\AsyncCommand\DependencyInjection;
use Enqueue\AsyncCommand\Commands;
use Enqueue\AsyncCommand\RunCommandProcessor;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
class AsyncCommandExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
foreach ($configs['clients'] as $client) {
// BC compatibility
if (!is_array($client)) {
$client = [
'name' => $client,
'command_name' => Commands::RUN_COMMAND,
'queue_name' => Commands::RUN_COMMAND,
'timeout' => 60,
];
}
$id = sprintf('enqueue.async_command.%s.run_command_processor', $client['name']);
$container->register($id, RunCommandProcessor::class)
->addArgument('%kernel.project_dir%')
->addArgument($client['timeout'])
->addTag('enqueue.processor', [
'client' => $client['name'],
'command' => $client['command_name'] ?? Commands::RUN_COMMAND,
'queue' => $client['queue_name'] ?? Commands::RUN_COMMAND,
'prefix_queue' => false,
'exclusive' => true,
])
->addTag('enqueue.transport.processor')
;
}
}
}