[Chapter 7] Multiple improvements + Event Handler + Projection + Projection Bus
This commit is contained in:
@@ -47,7 +47,6 @@ framework:
|
||||
|
||||
# Dead letter box
|
||||
failed_messages: '%env(MESSENGER_TRANSPORT_BASE_DSN)%/failed_messages'
|
||||
|
||||
routing:
|
||||
# With a proper UX, almost all the commands should
|
||||
# be run asynchronously.However, some commands can
|
||||
@@ -69,4 +68,4 @@ framework:
|
||||
# Projections should run asynchronously by default.
|
||||
# However, it's possible to run some synchronously
|
||||
# without getting the performance benefits.
|
||||
Cheeper\Chapter7\Application\Projection: projections_async
|
||||
Cheeper\Chapter7\Application\Projection: projections_async
|
||||
|
||||
@@ -104,8 +104,11 @@ services:
|
||||
# class: 'Cheeper\Chapter6\Infrastructure\Application\SymfonyProjectionBus'
|
||||
|
||||
# CHAPTER 7
|
||||
Cheeper\Chapter7\:
|
||||
resource: '../src/Cheeper/Chapter7/*'
|
||||
Cheeper\Chapter7\Application\:
|
||||
resource: '../src/Cheeper/Chapter7/Application/*'
|
||||
|
||||
Cheeper\Chapter7\Infrastructure\:
|
||||
resource: '../src/Cheeper/Chapter7/Infrastructure/*'
|
||||
|
||||
Cheeper\Chapter7\DomainModel\Author\AuthorRepository:
|
||||
class: 'Cheeper\Chapter7\Infrastructure\DomainModel\Author\DoctrineOrmAuthorRepository'
|
||||
@@ -130,13 +133,13 @@ services:
|
||||
|
||||
chapter7_command_handlers:
|
||||
namespace: Cheeper\Chapter7\Application\
|
||||
resource: '../src/Cheeper/Chapter7/Application/**/*CommandHandler.php'
|
||||
resource: '../src/Cheeper/Chapter7/Application/**/Command/*CommandHandler.php'
|
||||
tags:
|
||||
- { name: messenger.message_handler, bus: command.bus }
|
||||
|
||||
chapter7_event_handlers:
|
||||
namespace: Cheeper\Chapter7\Application\
|
||||
resource: '../src/Cheeper/Chapter7/Application/**/Symfony*EventHandler.php'
|
||||
resource: '../src/Cheeper/Chapter7/Application/**/*EventHandler.php'
|
||||
tags:
|
||||
- { name: messenger.message_handler, bus: event.bus }
|
||||
|
||||
@@ -148,7 +151,7 @@ services:
|
||||
|
||||
chapter7_projection_handlers:
|
||||
namespace: Cheeper\Chapter7\Application\
|
||||
resource: '../src/Cheeper/Chapter7/Application/**/Symfony*ProjectionHandler.php'
|
||||
resource: '../src/Cheeper/Chapter7/Application/**/*ProjectionHandler.php'
|
||||
tags:
|
||||
- { name: messenger.message_handler, bus: projection.bus }
|
||||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
rabbitmq:
|
||||
image: rabbitmq:management
|
||||
|
||||
ports:
|
||||
- "5672:5672"
|
||||
- "15672:15672"
|
||||
mysql:
|
||||
image: mysql
|
||||
image: mariadb
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
|
||||
@@ -16,7 +16,7 @@ final class AuthorFollowedEventHandler
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(AuthorFollowed $event): void
|
||||
public function __invoke(AuthorFollowed $event): void
|
||||
{
|
||||
$this->projectionHandler->__invoke(
|
||||
CountFollowersProjection::ofAuthor($event->toAuthorId())
|
||||
|
||||
@@ -18,7 +18,7 @@ final class NewAuthorSignedEventHandler
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(NewAuthorSigned $event): void
|
||||
public function __invoke(NewAuthorSigned $event): void
|
||||
{
|
||||
$this->followersProjector->__invoke(
|
||||
CreateFollowersCounterProjection::ofAuthor(
|
||||
|
||||
@@ -17,7 +17,7 @@ final class WhenNewAuthorSignedThenCreateTimelineProjectionEventHandler
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(NewAuthorSigned $event): void
|
||||
public function __invoke(NewAuthorSigned $event): void
|
||||
{
|
||||
$this->projector->__invoke(
|
||||
CreateTimelineProjection::ofAuthor(
|
||||
|
||||
@@ -21,7 +21,7 @@ final class CheepPostedEventHandler
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(CheepPosted $event): void
|
||||
public function __invoke(CheepPosted $event): void
|
||||
{
|
||||
$follows = $this->followRepository->toAuthorId(
|
||||
AuthorId::fromString($event->authorId())
|
||||
|
||||
@@ -25,6 +25,7 @@ final class SymfonyAuthorFollowedEventHandler implements MessageSubscriberInterf
|
||||
{
|
||||
yield AuthorFollowed::class => [
|
||||
'method' => 'handle',
|
||||
'bus' => 'event.bus',
|
||||
'from_transport' => 'events_async',
|
||||
];
|
||||
}
|
||||
@@ -26,6 +26,7 @@ final class SymfonyNewAuthorSignedEventHandler implements MessageSubscriberInter
|
||||
{
|
||||
yield NewAuthorSigned::class => [
|
||||
'method' => 'handle',
|
||||
'bus' => 'event.bus',
|
||||
'from_transport' => 'events_async',
|
||||
];
|
||||
}
|
||||
@@ -26,6 +26,7 @@ final
|
||||
{
|
||||
yield NewAuthorSigned::class => [
|
||||
'method' => 'handle',
|
||||
'bus' => 'event.bus',
|
||||
'from_transport' => 'events_async',
|
||||
];
|
||||
}
|
||||
@@ -25,7 +25,8 @@ final class SymfonyCheepPostedEventHandler implements MessageSubscriberInterface
|
||||
{
|
||||
yield CheepPosted::class => [
|
||||
'method' => 'handle',
|
||||
'from_transport' => 'chapter7_events',
|
||||
'bus' => 'event.bus',
|
||||
'from_transport' => 'events',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ final class SymfonyAddCheepToTimelineProjectionHandler implements MessageSubscri
|
||||
{
|
||||
yield AddCheepToTimelineProjection::class => [
|
||||
'method' => 'handle',
|
||||
'from_transport' => 'chapter7_async_projections',
|
||||
'bus' => 'projection.bus',
|
||||
'from_transport' => 'projections_async',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user