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

!!! FEATURE: Bind ContentGraph to workspace #5028

Merged
merged 32 commits into from
May 11, 2024

Conversation

kitsunet
Copy link
Member

@kitsunet kitsunet commented May 5, 2024

The ContentGraph is now always bound to a WorkspaceName and ContentStreamId combination.
The internal! ProjectionState of the ContentGraph is now the ContentGraphFinder which allows you to get an instance of the ContentGraph bound to a combination (usually by giving only the WorkspaceName).

The userland way to access the content graph is to ask the content repository:

ContentRepository::getContentGraph(WorkspaceName)

Upgrade instructions

The WorkspaceName must be passed along to get a subgraph instead of the internal ContentStreamId:

- $subgraph = $contentRepository->getContentGraph()->getSubgraph(
-     $workspace->currentContentStreamId,
-     $dimensionSpacePoint,
-     VisibilityConstraints::withoutRestrictions()
- );              
+ $subgraph = $contentRepository->getContentGraph($workspace->workspaceName)->getSubgraph(
+     $dimensionSpacePoint,
+     VisibilityConstraints::withoutRestrictions()
+ );

This pr presents an in between step. Its for example currently not easily possible to get the WorkspaceName of a Node, but that will be solved in a following pr see also #4564.
In this intermediate step, one must ask the workspace finder first to resolve a workspace for content stream which then can be passed to getContentGraph (see how ContentRepositoryRegistry::subgraphForNode handles it internally)

Review instructions

Followups: #5038
Neos Ui adjustments: neos/neos-ui#3775

@github-actions github-actions bot added the 9.0 label May 5, 2024
@kitsunet

This comment was marked as outdated.

@kitsunet kitsunet changed the title Feature/content graph bound TASK: ContentGraph bound to Workspace May 5, 2024
@github-actions github-actions bot added the Task label May 5, 2024
The ContentGraph is now always bound to a
`WorkspaceName` and `ContentStreamId` combination.
The ProjectionState of the ContentGraph is now
the `ContentGraphFinder` which allows you to get
an instance of the `ContentGraph` bound to a
combination (usually by giving only the `WorkspaceName`).

The userland way is to use

`ContentRepository::getContentGraph(WorkspaceName)`
@kitsunet kitsunet force-pushed the feature/content-graph-bound branch from 5ba922d to 7d691d8 Compare May 6, 2024 07:35
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.

@kitsunet Thanks so much for putting a tremendous amount of time into this. I think it looks great already.
I just left some mostly nitpicky comments after a first quick pass mostly to dump my thoughts – no need to fix those (now).

One more important architectural choice is the stateful ContentGraphFinder.
If I get it right, it now needs a getInstances() method such that we can access (and reset the state of) all previously created CG instances in order to enable or disable their inMemory cache.
And then we need a reset() method to reset the instances for tests.

This is quite a lot of "burden" to an interface (and custom implementations) for some really low-level goals.
Maybe together we can come up with a slightly different mechanism to work with those runtime caches. But this is certainly no reason to block this one, we could always tweak it in a follow-up.

Great work!

@kitsunet
Copy link
Member Author

kitsunet commented May 6, 2024

@kitsunet Thanks so much for putting a tremendous amount of time into this. I think it looks great already. I just left some mostly nitpicky comments after a first quick pass mostly to dump my thoughts – no need to fix those (now).

One more important architectural choice is the stateful ContentGraphFinder. If I get it right, it now needs a getInstances() method such that we can access (and reset the state of) all previously created CG instances in order to enable or disable their inMemory cache. And then we need a reset() method to reset the instances for tests.

This is quite a lot of "burden" to an interface (and custom implementations) for some really low-level goals. Maybe together we can come up with a slightly different mechanism to work with those runtime caches. But this is certainly no reason to block this one, we could always tweak it in a follow-up.

Great work!

<3 Thank you!

Yes lets definitely have a look at those low level things, they were really an afterthought since I realized that definitely the tests do not like having the instances around. We could completely skip the cache, but then any cache within the CG or subgraph wouldn't be much use either because you get a fresh instance every time.

Co-authored-by: Bastian Waidelich <b.waidelich@wwwision.de>
Co-authored-by: Marc Henry Schultz <85400359+mhsdesign@users.noreply.github.com>
bwaidelich added 2 commits May 8, 2024 09:06
…unet/neos-development-collection into feature/content-graph-bound

# Conflicts:
#	Neos.ContentRepository.Core/Classes/ContentGraphFinder.php
@bwaidelich
Copy link
Member

@kitsunet I took the freedom to push our changes from yesterday (24cfa06) to this PR. I don't know if tests are still green because there is a conflict that I wasn't able to resolve

@kitsunet
Copy link
Member Author

Hah, net minus lines, nice!

@mhsdesign
Copy link
Member

UI Adjustments: neos/neos-ui#3775

Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

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

Wow. What a blast. As bastian had one last go through i also found some mininini things (just apply and merge :D)

Additionally i managed to get the Neos Ui e2e tests running in addition to the Neos ui adjustments i prepared.

So i consider this absolutely ready and it can be merged this evening!

kitsunet and others added 3 commits May 10, 2024 21:01
Co-authored-by: Marc Henry Schultz <85400359+mhsdesign@users.noreply.github.com>
Co-authored-by: Marc Henry Schultz <85400359+mhsdesign@users.noreply.github.com>
@kitsunet
Copy link
Member Author

kitsunet commented May 10, 2024

Note for later:
Interesting that removal of the "doesNotExistYet" check did not lead any test to fail. Might be worth adding a test that checks that handling a command that tries to create an already existing ContentStream actually fails with the (re-added) exception.

@mhsdesign mhsdesign changed the title TASK: ContentGraph bound to Workspace FEATURE: Bind ContentGraph to workspace May 11, 2024
@mhsdesign mhsdesign enabled auto-merge May 11, 2024 07:56
@mhsdesign
Copy link
Member

Wow now its finally done. Thx for the plenty adjustments and your motivation.

@bwaidelich do you want to +1 as well?

@mhsdesign mhsdesign changed the title FEATURE: Bind ContentGraph to workspace !!! FEATURE: Bind ContentGraph to workspace May 11, 2024
@mhsdesign mhsdesign disabled auto-merge May 11, 2024 09:12
@mhsdesign mhsdesign enabled auto-merge May 11, 2024 09:12
@mhsdesign mhsdesign merged commit 0a2264e into neos:9.0 May 11, 2024
8 checks passed
@bwaidelich
Copy link
Member

@mhsdesign being trigger-happy again without even waiting for the checks to pass :)

@mhsdesign
Copy link
Member

Haha lol idk this was automerge? 😂

mhsdesign added a commit to mhsdesign/neos-development-collection that referenced this pull request May 20, 2024
…Graph directly

$this->projectedNodeIterator->nodeAggregatesOfType
has been rewritten to
$this->contentGraph->findNodeAggregatesByType

The `ProjectedNodeIterator` was before neos#5028 required to encapsulate `findNodeAggregatesByType` to only work on the live workspace.
neos-bot pushed a commit to neos/contentrepository-structureadjustment that referenced this pull request May 22, 2024
…Graph directly

$this->projectedNodeIterator->nodeAggregatesOfType
has been rewritten to
$this->contentGraph->findNodeAggregatesByType

The `ProjectedNodeIterator` was before neos/neos-development-collection#5028 required to encapsulate `findNodeAggregatesByType` to only work on the live workspace.
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.

4 participants