Open skurfuerst opened 5 years ago
After letting the proposal sink in for a few days it still feels a little awkward to access a "foreign" (as in: different Bounded Context) Read Model from the Write Side.
But it might be a very pragmatic solution that just works out in practice – we'll have to give it a try.
I'll introduce an external Command Bus (league/tactician
) to the CR to see if this works.
Nevertheless I want to add some more potential alternatives for the record:
NodeAggregateWasRemoved
event (probably not viable because there could be thousands of them)ContentStream X
@ Version Y
and ContentStream X'
@ Version Y'
(quite interesting IMO but that would mean a major change in the inner workings of the Graph and it might just be too complex & slow in practice)¹ It's probably not feasible to have an actual Aggregate that reconstitutes itself in memory – instead it could always materialize it's state in some database as soon as new events come in
See first draft: https://github.com/neos/contentrepository-development-collection/pull/104 (I moved the longer comment to the PR)
After our last ESCR talk I think that we need something other than a (global) Command Bus. Instead it should (IMO) be an instance of the "Content Repository" that will act as single authority for...
In that sense it is a Command Bus, but not a global one. That way we could handle commands for different CR instances "at the same time". Besides, the API will be easier to use because the correct CommandHandler instance does not need to be known and it could be a single public method, like:
$neosCR->handle(new CreateNodeVariant(...));
It is to be defined, what the "Core Read Models" are, but I think it should be the Content(Sub)Graph
and some kind of Diff
between two content streams (that also considers deleted nodes)
We need something more specific than (global) event listeners. Instead I could think of two kinds of extensions:
Concept for hooking into the Command / Event Flow
(Discussion @bwaidelich, @kitsunet , @skurfuerst )
Use Cases
Proposal
Implications
We see the Neos UI in the example below as separate application
e.g. for the Neos UI to remember to which document a deleted node belongs, the Neos UI would hook into the following Commands:
On DeleteNode, it will read the projection and remember the parent document node. Remembering in this case can mean directly storing it in the database; or working as a separate event-sourced application (with optionally a separate event store as well).
On PublishNode, we will copy the "Deleted Node" lines from our custom storage table, to the target ContentStream (if the target is not the live WS).
This leaves us with a small inconsistency window, as the separate application has different consistency guarantees. However, for our cases this is very very likely not a problem.
Alternatives (not suggested)