Skip to content

Commit

Permalink
Remove ProjectionCatchUpTriggerInterface and implementations
Browse files Browse the repository at this point in the history
...for now
  • Loading branch information
bwaidelich committed Apr 17, 2024
1 parent 7cc13ed commit fc6ec5c
Show file tree
Hide file tree
Showing 16 changed files with 14 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function createNodesForPerformanceTest(int $nodesPerLevel, int $levels):
NodeAggregateClassification::CLASSIFICATION_ROOT,
);

$this->eventPersister->publishEvents(new EventsToPublish(
$this->eventPersister->publishEvents($this->contentRepository, new EventsToPublish(
$this->contentStreamEventStream->getEventStreamName(),
Events::with($rootNodeAggregateWasCreated),
ExpectedVersion::ANY()
Expand All @@ -103,7 +103,7 @@ public function createNodesForPerformanceTest(int $nodesPerLevel, int $levels):
$sumSoFar = 0;
$events = [];
$this->createHierarchy($rootNodeAggregateId, 1, $levels, $nodesPerLevel, $sumSoFar, $events);
$this->eventPersister->publishEvents(new EventsToPublish(
$this->eventPersister->publishEvents($this->contentRepository, new EventsToPublish(
$this->contentStreamEventStream->getEventStreamName(),
Events::fromArray($events),
ExpectedVersion::ANY()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceTitle;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteTrait;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\DefaultCatchUpTrigger;
use Neos\EventStore\Exception\ConcurrencyException;
use Neos\Flow\Tests\FunctionalTestCase;
use PHPUnit\Framework\Assert;
Expand Down
2 changes: 1 addition & 1 deletion Neos.ContentRepository.Core/Classes/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function handle(CommandInterface $command): object
$eventsToPublish->expectedVersion,
);

$this->eventPersister->publishEvents($eventsToPublish);
$this->eventPersister->publishEvents($this, $eventsToPublish);
return new class {
/**
* @deprecated backwards compatibility layer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Neos\ContentRepository\Core\EventStore;

use Neos\ContentRepository\Core\Projection\ProjectionCatchUpTriggerInterface;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Projection\Projections;
use Neos\ContentRepository\Core\Projection\WithMarkStaleInterface;
use Neos\EventStore\EventStoreInterface;
Expand All @@ -23,7 +23,6 @@ final class EventPersister
{
public function __construct(
private readonly EventStoreInterface $eventStore,
private readonly ProjectionCatchUpTriggerInterface $projectionCatchUpTrigger,
private readonly EventNormalizer $eventNormalizer,
private readonly Projections $projections,
) {
Expand All @@ -33,7 +32,7 @@ public function __construct(
* @param EventsToPublish $eventsToPublish
* @throws ConcurrencyException in case the expectedVersion does not match
*/
public function publishEvents(EventsToPublish $eventsToPublish): void
public function publishEvents(ContentRepository $contentRepository, EventsToPublish $eventsToPublish): void
{
if ($eventsToPublish->events->isEmpty()) {
return;
Expand All @@ -53,7 +52,7 @@ public function publishEvents(EventsToPublish $eventsToPublish): void
$projection->markStale();
}
}
$this->projectionCatchUpTrigger->triggerCatchUp();
$contentRepository->catchUpProjections();
}

private function normalizeEvent(EventInterface|DecoratedEvent $event): Event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Neos\ContentRepository\Core\Feature\WorkspaceCommandHandler;
use Neos\ContentRepository\Core\Infrastructure\Property\PropertyConverter;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\Projection\ProjectionCatchUpTriggerInterface;
use Neos\ContentRepository\Core\Projection\ProjectionsAndCatchUpHooks;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\User\UserIdProviderInterface;
Expand All @@ -53,7 +52,6 @@ public function __construct(
ContentDimensionSourceInterface $contentDimensionSource,
Serializer $propertySerializer,
ProjectionsAndCatchUpHooksFactory $projectionsAndCatchUpHooksFactory,
private readonly ProjectionCatchUpTriggerInterface $projectionCatchUpTrigger,
private readonly UserIdProviderInterface $userIdProvider,
private readonly ClockInterface $clock,
) {
Expand Down Expand Up @@ -165,7 +163,6 @@ private function buildEventPersister(): EventPersister
if (!$this->eventPersister) {
$this->eventPersister = new EventPersister(
$this->projectionFactoryDependencies->eventStore,
$this->projectionCatchUpTrigger,
$this->projectionFactoryDependencies->eventNormalizer,
$this->projectionsAndCatchUpHooks->projections,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ private function handlePublishWorkspace(
$baseWorkspace = $this->requireBaseWorkspace($workspace, $contentRepository);

$this->publishContentStream(
$contentRepository,
$workspace->currentContentStreamId,
$baseWorkspace->currentContentStreamId
);
Expand Down Expand Up @@ -281,6 +282,7 @@ private function handlePublishWorkspace(
* @throws \Exception
*/
private function publishContentStream(
ContentRepository $contentRepository,
ContentStreamId $contentStreamId,
ContentStreamId $baseContentStreamId,
): void {
Expand Down Expand Up @@ -332,6 +334,7 @@ private function publishContentStream(
}
try {
$this->eventPersister->publishEvents(
$contentRepository,
new EventsToPublish(
$baseWorkspaceContentStreamName->getEventStreamName(),
Events::fromArray($events),
Expand Down Expand Up @@ -540,6 +543,7 @@ function () use ($matchingCommands, $contentRepository, $baseWorkspace): void {

// 5) take EVENTS(MATCHING) and apply them to base WS.
$this->publishContentStream(
$contentRepository,
$command->contentStreamIdForMatchingPart,
$baseWorkspace->currentContentStreamId
);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Neos\ContentRepository\Core\Projection;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\EventStore\EventPersister;

/**
Expand All @@ -17,7 +18,7 @@
interface WithMarkStaleInterface
{
/**
* Triggered directly before {@see ProjectionCatchUpTriggerInterface::triggerCatchUp()} is called;
* Triggered directly before {@see ContentRepository::catchUpProjections()} is called;
* by the {@see EventPersister::publishEvents()} method.
*
* Can be f.e. used to disable caches inside the Projection State.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function fixError(StructureAdjustment $adjustment): void
$remediation = $adjustment->remediation;
$eventsToPublish = $remediation();
assert($eventsToPublish instanceof EventsToPublish);
$this->eventPersister->publishEvents($eventsToPublish);
$this->eventPersister->publishEvents($this->contentRepository, $eventsToPublish);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features\WorkspaceCreation;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features\WorkspaceDiscarding;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features\WorkspacePublishing;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\DefaultCatchUpTrigger;
use Neos\EventStore\EventStoreInterface;
use PHPUnit\Framework\Assert;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function publishEvent(string $eventType, StreamName $streamName, array
->getValue($eventPersister);
$event = $eventNormalizer->denormalize($artificiallyConstructedEvent);

$eventPersister->publishEvents(new EventsToPublish(
$eventPersister->publishEvents($this->currentContentRepository, new EventsToPublish(
$streamName,
Events::with($event),
ExpectedVersion::ANY()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Neos\ContentRepository\Core\Projection\CatchUpHookFactoryInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ProjectionCatchUpTriggerInterface;
use Neos\ContentRepository\Core\Projection\ProjectionFactoryInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\User\UserIdProviderInterface;
Expand All @@ -23,7 +22,6 @@
use Neos\ContentRepositoryRegistry\Factory\ContentDimensionSource\ContentDimensionSourceFactoryInterface;
use Neos\ContentRepositoryRegistry\Factory\EventStore\EventStoreFactoryInterface;
use Neos\ContentRepositoryRegistry\Factory\NodeTypeManager\NodeTypeManagerFactoryInterface;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\ProjectionCatchUpTriggerFactoryInterface;
use Neos\ContentRepositoryRegistry\Factory\UserIdProvider\UserIdProviderFactoryInterface;
use Neos\EventStore\EventStoreInterface;
use Neos\Flow\Annotations as Flow;
Expand Down Expand Up @@ -155,7 +153,6 @@ private function buildFactory(ContentRepositoryId $contentRepositoryId): Content
$this->buildContentDimensionSource($contentRepositoryId, $contentRepositorySettings),
$this->buildPropertySerializer($contentRepositoryId, $contentRepositorySettings),
$this->buildProjectionsFactory($contentRepositoryId, $contentRepositorySettings),
$this->buildProjectionCatchUpTrigger($contentRepositoryId, $contentRepositorySettings),
$this->buildUserIdProvider($contentRepositoryId, $contentRepositorySettings),
$clock,
);
Expand Down Expand Up @@ -249,17 +246,6 @@ private function buildProjectionsFactory(ContentRepositoryId $contentRepositoryI
return $projectionsFactory;
}

/** @param array<string, mixed> $contentRepositorySettings */
private function buildProjectionCatchUpTrigger(ContentRepositoryId $contentRepositoryId, array $contentRepositorySettings): ProjectionCatchUpTriggerInterface
{
isset($contentRepositorySettings['projectionCatchUpTrigger']['factoryObjectName']) || throw InvalidConfigurationException::fromMessage('Content repository "%s" does not have projectionCatchUpTrigger.factoryObjectName configured.', $contentRepositoryId->value);
$projectionCatchUpTriggerFactory = $this->objectManager->get($contentRepositorySettings['projectionCatchUpTrigger']['factoryObjectName']);
if (!$projectionCatchUpTriggerFactory instanceof ProjectionCatchUpTriggerFactoryInterface) {
throw InvalidConfigurationException::fromMessage('projectionCatchUpTrigger.factoryObjectName for content repository "%s" is not an instance of %s but %s.', $contentRepositoryId->value, ProjectionCatchUpTriggerFactoryInterface::class, get_debug_type($projectionCatchUpTriggerFactory));
}
return $projectionCatchUpTriggerFactory->build($contentRepositoryId, $contentRepositorySettings['projectionCatchUpTrigger']['options'] ?? []);
}

/** @param array<string, mixed> $contentRepositorySettings */
private function buildUserIdProvider(ContentRepositoryId $contentRepositoryId, array $contentRepositorySettings): UserIdProviderInterface
{
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions Neos.ContentRepositoryRegistry/Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ Neos:
contentDimensionSource:
factoryObjectName: Neos\ContentRepositoryRegistry\Factory\ContentDimensionSource\ConfigurationBasedContentDimensionSourceFactory

projectionCatchUpTrigger:
factoryObjectName: Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\DefaultProjectionCatchUpTriggerFactory

userIdProvider:
factoryObjectName: Neos\ContentRepositoryRegistry\Factory\UserIdProvider\StaticUserIdProviderFactory

Expand Down

0 comments on commit fc6ec5c

Please sign in to comment.