This problem statement is around one UI component, 3 service components. The current design of the application is like:
- UI makes request to Service-A to get data
- Service-A first makes a call to Service-B to get list of items. There can be multiple calls between Service-A and Service-B if there are huge number of records. For example, Service-A asks service-B to return all avaialble items. Service-B will return data in pagination form i.e. first page will have 100 items, seconds page will give next 100 items and so on until all the items are retrieved. Here Service-A will specify the page number while fetching items from Service-B
- Once all the items are collected(in Step-2), Service-A will make call to Service-C to get details about each item. Service-C can have data for all items or only few of the items. Service-C also works on pagination like mentioned in Step-2.
- UI keeps polling Service-A for data in every few seconds to see if data is ready.
- Once Service-A has got all item details from Service-C, it sends data back to UI.
Above design results in a endless spinner on UI screen if Service-B and Service-C are slow in returning data.
Now I want to improve this design in a way that Service-A does not wait for both Service-B and Service-C to send all data and can return data to UI in chunks. There is no pagination on UI as of now but a scrolling based pagination can be added like load more data when user scrolls.
Could anyone please suggest a better way of implementing this flow?
Kindly let me know in case more details are required.
Thanks a ton in advance. :)