I am planning to make a service which will have simple REST APIs and will have a database in backend. I also wanted to add a logic to listen to notifications emitted by other service and there is some business logic which will update the row in the database.
For updating the database row from Notifications, I can think of 2 approaches:
Should I create a API which is kind of internal to just used by service and this listener process calls this API instead of directly updating the database?
Listener process directly updates the service.
I can see some pros and cons of each approach. In Approach 1, we are adding a REST API unnecessarily which is never used by clients.
In Approach 2, we are giving one backside way to reach the database instead of all the requests coming from REST API.
Can someone help me here to tell if one of them is anti-pattern and which one is better to use?
Go to Source