Open paaneko opened 4 months ago
Thank you for your thoughtful proposal and for considering different ways to structure our repositories We really appreciate your input and the effort you've put into this
While the idea of separating read and write repositories has its merits, we're concerned that it might lead us to lose some of the advantages we currently enjoy with Doctrine's repository pattern and our api platform's CRUD operations If we were to implement separate repositories for reading and writing, we would need to maintain three repositories (one for read, one for write, and one to combine them) instead of one, which could increase complexity and maintenance overhead
To address the read/write concerns you mentioned, we believe a load balancer could effectively distribute SQL queries between replicas and the primary node, helping manage the load and optimize performance Alternatively, we could manage this at the application level using different entity managers or connections for different database instances, providing us with the control we need without restructuring our repository system
We highly value your contributions and encourage you to continue sharing your insights Let's keep this dialogue open and collaborative as we work towards the best solutions for our platform
Thank you for your detailed reply! I don't think I can come up with a better solution, your described load balancer
and entity managers
looks like a good one)
This proposal implies dividing common repositories, that can hold
save
,find
,get
,delete
methods into two -read (find, get)
andwrite (save, delete)
. Butwrite
repository interfaces would be stored in theDomain
layer, andread
repositories in theApplication
layer, and their implementations as usual in theInfrastructure
layer, e.g. as shown on the picture:And also introduce a rule that
read
repositories are allowed to read data from any BCs. This should solve the problem, when in the future, particular BC needs to get data from some other BCs, but without importing dependencies into the Domain layer.P.S. I'm not a big DDD guru, but IMHO this is a good idea.
WDYT?