This is in context of a distributed computing. There is a Service A which owns a database and hosts APIs for updating an entities in this database.
As time went by, the service has evolved and we are about to add a complex capability to this service. This capability can be separated out to a service of it's own. But it updates the same entity which service A owns.
Now what i'm not able to find a definitive answer for, is whether the new Service B should use Service A's APIs to update the entity or should it be allowed to directly access the DB.
- This new capability is a capability of service A i.e, It is tightly coupled to service A .
- If we were to give direct DB access, we would maintain the DB code in a common library
- Ownership boundary of the entities will be well defined and clear
- Additional network and network latency
Direct DB access:
- We can get rid of the un-necessary auth and network latency
- Ownership boundary of the entity becomes blurry.
In my mind as the common code is in a library and we are just changing where the code runs, i don't see the value of using APIs
Overall my questions are:
- Does giving direct DB access really blur entity boundaries?
- Are there any long term cons of giving direct DB access which I'm missing.