The data returned to the front end comes from multiple microservices. Where should the data be integrated and returned?

problem description

the data returned to the front end comes from multiple microservices. Where should the data be integrated and returned?
for example, there is an API / getOrderInfo to obtain order information
you need to obtain user information from service A, order information from service B, inventory information from service C, etc.
is it better to call one interface directly or multiple interfaces to return?

May.31,2022

the getOrderInfo interface is integrated in the same service. Get user information from other services that are also called in this service. Encapsulate


call an interface.
for example, if service N has an interface getOrderInfo, the calling process is client--> service NMI-> service a+b+c , and all data is returned from N to the client


    .
  1. depends on the core data you want to obtain. For example, if you use the order information API getOrderInfo , the core data must be an order, then the interface is written in the order service module. Interface processing to call other services to obtain inventory and other related data.
  2. is it better to call one interface or multiple interfaces? From the business analysis, if the data is not relevant, multiple interfaces are called to obtain a variety of data. In a way, an interface should return only one kind of data, for example, the user information and inventory information mentioned above are based on the order, so it also belongs to the order information. This example can simply call an interface.
Menu