Message passing between actors
Merely logging the API response is not very useful. To traverse the follower graph, we must perform the following:
- Check the return code of the response to make sure that the GitHub API was happy with our request
- Parse the response as JSON
- Extract the login names of the followers and, if we have not fetched them already, push them into the queue
You learned how to do all these things in Chapter 7, Web APIs, but not in the context of actors.
We could just add the additional processing steps to the receive
method of our Fetcher
actor: we could add further transformations to the API response by future composition. However, having actors do several different things, and possibly failing in several different ways, is an anti-pattern: ...
Get Scala for Data Science now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.