I'm not sure how to best ask this, as it's the first time I have to tackle such stuff. It might be that it's a common problem and I'm just using the wrong keywords to search. Basically, imagine a microservice needs (as part of its data) the ID of some objects managed by another microservice. For example, Users and Orders: the Orders microservice needs the ID of the user who placed the order, as exposed by the Users microservice.
This leads to two questions:
- Is it good practice to save the user id for a user in the orders microservice (that is, in the database that backs the microservice)? (or, in the general case, the ID of an object managed by a microservice in another one)
- How does a consumer of either API finds out the user ID for a user (or the order ID) to use to start making actual REST API calls? Normally only some generic identifier comes from the application, like an email address or telephone number. I guess there must be some kind of mapping service which, given an email or a phone number, returns the user ID to use for the REST calls? Where should this translation service be exposed? In the Users microservice?
Thanks