Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/PdoEventSourcing/src/Config/EventSourcingModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Ecotone\EventSourcing\ProjectionSetupConfiguration;
use Ecotone\EventSourcing\ProjectionStreamSource;
use Ecotone\EventSourcing\Prooph\LazyProophEventStore;
use Ecotone\EventSourcing\Prooph\LazyProophProjectionManager;
use Ecotone\EventSourcing\ProophEventMapper;
use Ecotone\Messaging\Attribute\Asynchronous;
use Ecotone\Messaging\Attribute\EndpointAnnotation;
Expand Down Expand Up @@ -61,6 +62,7 @@
use Ecotone\Messaging\Handler\InterfaceToCallRegistry;
use Ecotone\Messaging\Handler\Processor\MethodInvoker\Converter\HeaderBuilder;
use Ecotone\Messaging\Handler\Processor\MethodInvoker\Converter\PayloadBuilder;
use Ecotone\Messaging\Handler\ReferenceSearchService;
use Ecotone\Messaging\Handler\Router\RouterProcessorBuilder;
use Ecotone\Messaging\Handler\ServiceActivator\MessageProcessorActivatorBuilder;
use Ecotone\Messaging\Handler\ServiceActivator\ServiceActivatorBuilder;
Expand Down Expand Up @@ -263,6 +265,15 @@ public function prepare(Configuration $messagingConfiguration, array $extensionO
new Reference($eventSourcingConfiguration->getConnectionReferenceName(), ContainerImplementation::NULL_ON_INVALID_REFERENCE),
]));

$messagingConfiguration->registerServiceDefinition(LazyProophProjectionManager::class,
new Definition(LazyProophProjectionManager::class, [
Reference::to(EventSourcingConfiguration::class),
$this->projectionSetupConfigurations,
Reference::to(ReferenceSearchService::class),
Reference::to(LazyProophEventStore::class),
]),
);

$this->registerProjections($serviceConfiguration, $interfaceToCallRegistry, $moduleReferenceSearchService, $messagingConfiguration, $extensionObjects, $eventSourcingConfiguration);
foreach ($this->projectionLifeCycleServiceActivators as $serviceActivator) {
$messagingConfiguration->registerMessageHandler($serviceActivator);
Expand Down Expand Up @@ -437,7 +448,7 @@ private function registerProjectionManager(Configuration $configuration, EventSo

private function registerProjectionManagerAction(string $methodName, array $endpointConverters, array $gatewayConverters, EventSourcingConfiguration $eventSourcingConfiguration, Configuration $configuration, ?string $consoleCommandName = null, array $consoleCommandParameters = []): void
{
$messageHandlerBuilder = ProjectionManagerBuilder::create($methodName, $endpointConverters, $eventSourcingConfiguration, $this->projectionSetupConfigurations);
$messageHandlerBuilder = ProjectionManagerBuilder::create($methodName, $endpointConverters, $eventSourcingConfiguration);
$configuration->registerMessageHandler($messageHandlerBuilder);
$configuration->registerGatewayBuilder(
GatewayProxyBuilder::create($eventSourcingConfiguration->getProjectManagerReferenceName(), ProjectionManager::class, $methodName, $messageHandlerBuilder->getInputMessageChannelName())
Expand Down Expand Up @@ -583,7 +594,7 @@ private function registerProjections(ServiceConfiguration $serviceConfiguration,

/** Our main entrypoint for projection execution */
$messagingConfiguration->registerMessageHandler(
(new ProjectionExecutorBuilder($projectionSetupConfiguration, $this->projectionSetupConfigurations, 'execute'))
(new ProjectionExecutorBuilder($projectionSetupConfiguration, 'execute'))
->withEndpointId($projectionSetupConfiguration->getProjectionEndpointId())
->withInputChannelName($projectionSetupConfiguration->getProjectionInputChannel())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class ProjectionExecutorBuilder extends InputOutputMessageHandlerBuilder impleme
{
public function __construct(
private ProjectionSetupConfiguration $projectionSetupConfiguration,
private array $projectSetupConfigurations,
private string $methodName
) {
}
Expand All @@ -41,12 +40,7 @@ public function compile(MessagingContainerBuilder $builder): Definition
$projectionEventHandler = new Definition(
ProjectionEventHandler::class,
[
new Definition(LazyProophProjectionManager::class, [
Reference::to(EventSourcingConfiguration::class),
$this->projectSetupConfigurations,
Reference::to(ReferenceSearchService::class),
Reference::to(LazyProophEventStore::class),
]),
new Reference(LazyProophProjectionManager::class),
$this->projectionSetupConfiguration,
Reference::to(ConversionService::REFERENCE_NAME),
]
Expand Down
18 changes: 3 additions & 15 deletions packages/PdoEventSourcing/src/Config/ProjectionManagerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Ecotone\EventSourcing\Prooph\LazyProophEventStore;
use Ecotone\EventSourcing\Prooph\LazyProophProjectionManager;
use Ecotone\Messaging\Config\Container\Definition;
use Ecotone\Messaging\Config\Container\InterfaceToCallReference;
use Ecotone\Messaging\Config\Container\MessagingContainerBuilder;
use Ecotone\Messaging\Config\Container\Reference;
use Ecotone\Messaging\Handler\InputOutputMessageHandlerBuilder;
Expand All @@ -23,13 +24,11 @@ class ProjectionManagerBuilder extends InputOutputMessageHandlerBuilder
{
/**
* @param ParameterConverterBuilder[] $parameterConverters
* @param ProjectionSetupConfiguration[] $projectionSetupConfigurations
*/
private function __construct(
private string $methodName,
private array $parameterConverters,
private EventSourcingConfiguration $eventSourcingConfiguration,
private array $projectionSetupConfigurations
) {
}

Expand All @@ -41,9 +40,8 @@ public static function create(
string $methodName,
array $parameterConverters,
EventSourcingConfiguration $eventSourcingConfiguration,
array $projectionSetupConfigurations
): static {
return new self($methodName, $parameterConverters, $eventSourcingConfiguration, $projectionSetupConfigurations);
return new self($methodName, $parameterConverters, $eventSourcingConfiguration);
}

public function getInputMessageChannelName(): string
Expand All @@ -58,17 +56,7 @@ public function getInterceptedInterface(InterfaceToCallRegistry $interfaceToCall

public function compile(MessagingContainerBuilder $builder): Definition
{
$lazyProophProjectionManager = new Definition(
LazyProophProjectionManager::class,
[
new Reference(EventSourcingConfiguration::class),
$this->projectionSetupConfigurations,
new Reference(ReferenceSearchService::class),
new Reference(LazyProophEventStore::class),
]
);

return ServiceActivatorBuilder::createWithDefinition($lazyProophProjectionManager, $this->methodName)
return ServiceActivatorBuilder::create(LazyProophProjectionManager::class, new InterfaceToCallReference(LazyProophProjectionManager::class, $this->methodName))
->withMethodParameterConverters($this->parameterConverters)
->withInputChannelName($this->getInputMessageChannelName())
->compile($builder);
Expand Down
Loading