Comments (6)
I'll have a think about it. I personally don't use the required history and adding a method specifically for this seems a bit overkill. An option could also be to wrap the AggregateRootRepository into something that DOES hint it can through this, would that work for you?
from eventsauce.
I feel that the root of the problem is that:
public function retrieve(AggregateRootId $aggregateRootId): object;
in AggregateRootRepository
does not return ?object
. This would be the behavior I would expect (and have seen) for pretty much any Storage system.
If I ask for something and it does not exist, let me know. right now it auto-magically will create it. This might be intended behavior for some cases, but it is IMHO very non-intuitive. And it results in this situation with incompatible implementations.
But you could have the intuitive behavior:
interface AggregateRootRepository
{
public function retrieve(AggregateRootId $aggregateRootId): ?object;
}
and 2 implementations, one that returns ?object
and another that returns object
. No exception, no incompatibilities.
from eventsauce.
and if you feel like having only one ConstructingAggregateRootRepository
, you could even template it like this:
/**
* @template T of bool
*/
class ConstructingAggregateRootRepository
{
/**
* @param T $constructOnNoneExistant
*/
public function __construct(
string $aggregateRootClassName,
MessageRepository $messageRepository,
MessageDispatcher $dispatcher = null,
MessageDecorator $decorator = null,
bool $constructOnNoneExistant = true
)
/*
* @return (T is true ? object : ?object)
*/
public function retrieve(AggregateRootId $aggregateRootId): ?object
}
from eventsauce.
In terms of BC breaks:
- functionally it is the same (at runtime, the same output for the same inputs as the old code)
ConstructingAggregateRootRepository
is final, so more constructor parameters are OK- The SA is very different. However, for the 2 most widely used (Psalm and PHPStan) it would just ask for template types if the repository is assigned to a variable or being a return type.
from eventsauce.
Related to #48
There is a detailed explanation.
from eventsauce.
This will be fixed in v1.0. Thanks all.
from eventsauce.
Related Issues (20)
- Doctrine MessageRepository appears to have no upgrade path HOT 13
- Message::withHeader() no longer allows array value HOT 2
- Doubt about aggregate root version HOT 4
- Isn't replaying domain message events by default slow as hell HOT 15
- Examples of persisting snapshots to a database HOT 2
- Aggregate root HOT 3
- Projections
- Structure table
- Suggest snapshotting change HOT 2
- AggregateRootBehaviour should have a template on AggregateRootId HOT 3
- Use lambdas insterad of command objects? HOT 4
- DefaultHeadersDecorator order parameters deprecated HOT 6
- Move all tests to separate folder tests HOT 2
- Reconstituting a specific version HOT 8
- Missing "id" reference in docs HOT 1
- DoctrineOutboxRepository reserved words escaping HOT 1
- Type mismatched... Expected `AggregateRootId` found `AggregateRootIdType` HOT 1
- Storing messages in MongoDB HOT 2
- Help needed... Preconditions are not working in test scenarios HOT 2
- Your inputs on this would be very helpful
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventsauce.