Just wanted to know if cyclic dependency is something that one should avoid in microservice design.
For example, let's say we have a simple web store that sells fruit.
It could have:
- Account Service - where all information about accounts is stored
- Order Service - where all the information about orders is stored
- Fruit Stock Service - a simple listing of fruits, their availability is stock and prices.
Let's say that we want to forbid our users buying more than 10 bananas total. And put the info about banana availability on the screen.
So which is the better way to do it:
Have Fruit Stock Service make a request to a Order Service to get all previous user orders and return it with the bananas price and stock info. In this case we have a cyclic dependency because Order Service needs to know about fruit and Fruit Stock Service needs to know about orders
Have a separate request to Order Service (something like 'Can user 111 buy item 222'). In this case we have to make 2 separate request to know if we should show bananas to this user or not.