Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!! TASK: Introduce first level content repository projection #5272

Merged
merged 16 commits into from
Oct 22, 2024

Conversation

mhsdesign
Copy link
Member

@mhsdesign mhsdesign commented Oct 2, 2024

Replaces the quirky ContentRepositoryReadModelAdapterInterface with a new ContentGraphReadModelInterface that is a 1st level dependency to the ContentRepository.
This simplifies code flow and prevents CR instances without its main projection to be created.

Note

This is a breaking change because it changes the configuration format for the ContentRepositoryRegistry package from

Neos:
  ContentRepositoryRegistry:
    presets:
      'default':
        # ...
        projections:
          'Neos.ContentRepository:ContentGraph':
            catchUpHooks: # ...
          'Neos.Neos:DocumentUriPathProjection': #...

to

Neos:
  ContentRepositoryRegistry:
    presets:
      'default':
        # ...
        contentGraphProjection:
          catchUpHooks: #...
        projections:
          'Neos.Neos:DocumentUriPathProjection': #...

Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one and it's a good idea to move the countNodes() hack to the higher level interface.
I already added a couple of comments even though this is just a draft yet

Base automatically changed from task/add-workspace-contentstream-mapping-to-contentgraph to 9.0 October 17, 2024 11:11
@github-actions github-actions bot added the 9.0 label Oct 17, 2024
A ContentRepository cannot exist without this projection
Previously if called with `ProjectionStateInterface::class` it would return the first state which will then not be callable again by its fqn. Now only fqn are allowed.
Initially the interface logic was needed for interchangeable cr readmodel projection states
…ound to a workspace but cross content stream

Also since its internal and only used for the tests it a good to be hidden in the low level `ContentRepositoryReadModel` next to other low level methods
@mhsdesign mhsdesign force-pushed the task/cr-readmodel-first-level branch from f11e713 to fb56a07 Compare October 17, 2024 12:13
@mhsdesign mhsdesign marked this pull request as ready for review October 17, 2024 12:14
@mhsdesign mhsdesign changed the title TASK: CR readmodel first level TASK: Introduce first level content repository projection Oct 18, 2024
Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhsdesign This is a great start already, but I'm not yet super happy with the split in the CR core.
I have some rough ideas I would like to discuss with you at some point

Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First set of comments, looking great already.
What puzzles me is the distinction between contentRepositoryProjection (in configuration etc) but contentGraphReadModel

Comment on lines +160 to +161
if (in_array(ContentGraphReadModelInterface::class, class_implements($projectionStateClassName), true)) {
throw new \InvalidArgumentException(sprintf('Accessing the internal content repository projection state via %s(%s) is not allowed. Please use the API on the content repository instead.', __FUNCTION__, $projectionStateClassName), 1729338679);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: why not move this check to the top and keep the rest like before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then it would be more expensive imo as we call class_implements always and here its just to improve the error message ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as said above I would just allow it and thrash the check. it's a projectionstate after all, just one with better API to reach it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will have to disallow this with the CR Privileges because they enforce the constraints on the CR instance

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, ok fair enough. Then this place is fine for me.

Comment on lines +146 to +154
if (!isset($this->projectionStateCache)) {
foreach ($this->projectionsAndCatchUpHooks->projections as $projection) {
if ($projection instanceof ContentGraphProjectionInterface) {
continue;
}
$projectionState = $projection->getState();
$this->projectionStateCache[$projectionState::class] = $projectionState;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't completely get the implications of this, but why do we build up the runtime cache for all projections once any state is retrieved?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we did so previously almost as well just that we break on the first match, by building it once its more easy to grasp

@@ -141,18 +143,24 @@ public function handle(CommandInterface $command): void
*/
public function projectionState(string $projectionStateClassName): ProjectionStateInterface
{
if (!isset($this->projectionStateCache)) {
foreach ($this->projectionsAndCatchUpHooks->projections as $projection) {
if ($projection instanceof ContentGraphProjectionInterface) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So but that means you cannot get the CG projection here anymore? not sure that is good?!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a good thing (see comment above re PR privileges)

@bwaidelich bwaidelich changed the title TASK: Introduce first level content repository projection !!! TASK: Introduce first level content repository projection Oct 22, 2024
@bwaidelich bwaidelich merged commit 7c5ad8c into 9.0 Oct 22, 2024
10 checks passed
@bwaidelich bwaidelich deleted the task/cr-readmodel-first-level branch October 22, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants