Skip to content

Commit 9f2993f

Browse files
committed
[async-commands][async-events] Sync with latest design chagnes in core.
1 parent c2198da commit 9f2993f

File tree

7 files changed

+32
-28
lines changed

7 files changed

+32
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
services:
22
enqueue.async_command.run_command_processor:
33
class: 'Enqueue\AsyncCommand\RunCommandProcessor'
4-
public: public
54
arguments:
65
- '%kernel.project_dir%'
76
tags:
8-
- { name: 'enqueue.client.processor' }
7+
- { name: 'enqueue.command_subscriber', client: 'default' }

pkg/async-command/RunCommandProcessor.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public function process(PsrMessage $message, PsrContext $context): Result
4545
public static function getSubscribedCommand(): array
4646
{
4747
return [
48-
'processorName' => Commands::RUN_COMMAND,
49-
'queueName' => Commands::RUN_COMMAND,
50-
'queueNameHardcoded' => true,
48+
'command' => Commands::RUN_COMMAND,
49+
'queue' => Commands::RUN_COMMAND,
50+
'prefix_queue' => false,
5151
'exclusive' => true,
5252
];
5353
}

pkg/async-command/Tests/RunCommandProcessorTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function testShouldSubscribeOnRunCommand()
4343
$subscription = RunCommandProcessor::getSubscribedCommand();
4444

4545
$this->assertSame([
46-
'processorName' => Commands::RUN_COMMAND,
47-
'queueName' => Commands::RUN_COMMAND,
48-
'queueNameHardcoded' => true,
46+
'command' => Commands::RUN_COMMAND,
47+
'queue' => Commands::RUN_COMMAND,
48+
'prefix_queue' => false,
4949
'exclusive' => true,
5050
], $subscription);
5151
}

pkg/async-event-dispatcher/AsyncProcessor.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
namespace Enqueue\AsyncEventDispatcher;
44

5+
use Enqueue\Client\CommandSubscriberInterface;
56
use Enqueue\Consumption\Result;
67
use Interop\Queue\PsrContext;
78
use Interop\Queue\PsrMessage;
89
use Interop\Queue\PsrProcessor;
910
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1011

11-
class AsyncProcessor implements PsrProcessor
12+
class AsyncProcessor implements PsrProcessor, CommandSubscriberInterface
1213
{
1314
/**
1415
* @var Registry
@@ -20,10 +21,6 @@ class AsyncProcessor implements PsrProcessor
2021
*/
2122
private $dispatcher;
2223

23-
/**
24-
* @param Registry $registry
25-
* @param EventDispatcherInterface $dispatcher
26-
*/
2724
public function __construct(Registry $registry, EventDispatcherInterface $dispatcher)
2825
{
2926
$this->registry = $registry;
@@ -39,9 +36,6 @@ public function __construct(Registry $registry, EventDispatcherInterface $dispat
3936
$this->dispatcher = $dispatcher;
4037
}
4138

42-
/**
43-
* {@inheritdoc}
44-
*/
4539
public function process(PsrMessage $message, PsrContext $context)
4640
{
4741
if (false == $eventName = $message->getProperty('event_name')) {
@@ -57,4 +51,9 @@ public function process(PsrMessage $message, PsrContext $context)
5751

5852
return self::ACK;
5953
}
54+
55+
public static function getSubscribedCommand()
56+
{
57+
return Commands::DISPATCH_ASYNC_EVENTS;
58+
}
6059
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Enqueue\AsyncEventDispatcher;
4+
5+
final class Commands
6+
{
7+
const DISPATCH_ASYNC_EVENTS = 'symfony.dispatch_async_events';
8+
}

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99

1010
class AsyncEventsPass implements CompilerPassInterface
1111
{
12-
/**
13-
* {@inheritdoc}
14-
*/
15-
public function process(ContainerBuilder $container)
12+
public function process(ContainerBuilder $container): void
1613
{
1714
if (false == $container->hasDefinition('enqueue.events.async_listener')) {
1815
return;
@@ -45,8 +42,9 @@ public function process(ContainerBuilder $container)
4542
;
4643

4744
$container->getDefinition('enqueue.events.async_processor')
48-
->addTag('enqueue.client.processor', [
49-
'topicName' => 'event.'.$event,
45+
->addTag('enqueue.processor', [
46+
'topic' => 'event.'.$event,
47+
'client' => 'default',
5048
])
5149
;
5250

@@ -78,8 +76,9 @@ public function process(ContainerBuilder $container)
7876
;
7977

8078
$container->getDefinition('enqueue.events.async_processor')
81-
->addTag('enqueue.client.processor', [
79+
->addTag('enqueue.processor', [
8280
'topicName' => 'event.'.$event,
81+
'client' => 'default',
8382
])
8483
;
8584

pkg/async-event-dispatcher/Resources/config/services.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ services:
3333
- '@enqueue.events.event_dispatcher'
3434
tags:
3535
-
36-
name: 'enqueue.client.processor'
37-
topicName: '__command__'
38-
processorName: '%enqueue_events_queue%'
39-
queueName: '%enqueue_events_queue%'
40-
queueNameHardcoded: true
36+
name: 'enqueue.processor'
37+
command: 'symfony.dispatch_async_events'
38+
queue: '%enqueue_events_queue%'
39+
queue_prefixed: false
4140
exclusive: true
4241

4342
enqueue.events.php_serializer_event_transofrmer:

0 commit comments

Comments
 (0)