I reproduced a small example of kerkour's Rust Clean Architecture on the Rust Playground.
The code is just an example and the methods code makes no sense at all.
This architecture leaks DB information to the service layer (for example methods like: find_namespace_and_membership
have db: &DB
argument with pub type DB = sqlx::PgPool
).
This is because, quoting the author:
You may ask: Why put the
db
in theService
and not in therepository
if it's the repository that interacts with the database?
Because we will sometimes need to call the repository's methods within transactions. So we need the repository's methods to be generics over 'normal' database operations and transactions.
I just one one question for you: Is it really difficult to test Service methods like find_namespace_and_membership
without using a real DB and mocking it?
I don't know where to start, but if this is feasible I can use this architecture instead of other ones because it is much, much more practical and RAD.
I examined other architectures today (this one for example) and this is the most RAD one!
There are actually two questions, excuse me: is there something untestable / unscalable that I'm missing in this architecture right now?