Refer to GeographicService.scala
. The code fetches Weather and nearby places information (both http
calls to an end-point) and merges the 2 end-points responses to produce meaningful information as JSON string.
- Part 1
- Use
Future
’sflatMap
to get the aggregate result. - Re-write the same using
for
-comprehension. - In each case strive to use minimal variables.
- Measure time taken in each case and compare the results. You may use the
time
function provided therein.
- Use
- Part 2
- Running futures one after another turned out to be the same which the earlier sequential code was doing. By using Futures, we simply converted synchronous calls to asynchronous ones, devoid of any speed benefit.
- Your task is to make this as fast as possible by running the futures in parallel. Make necessary modifications to both the versions of your earlier code.
- Measure time taken in each case and compare the results and also with Part 1 cases.