Fetcher actors
The workhorse of our application is the fetcher, the actor responsible for fetching the follower details from GitHub. In the first instance, our actor will accept a single message, Fetch(user)
. It will fetch the followers corresponding to user
and log the response to screen. We will use the recipes developed in Chapter 7, Web APIs, to query the GitHub API with an OAuth token. We will inject the token through the actor constructor.
Let's start with the companion object. This will contain the definition of the Fetch(user)
message and two factory methods to create the Props
instances. You can find the code examples for this section in the chap09/fetchers_alone
directory in the sample code provided with this book (https://github.com/pbugnion/s4ds):
// Fetcher.scala import akka.actor._ import scalaj.http._ import scala.concurrent.Future object Fetcher { // message definitions case class Fetch(login:String) // Props factory definitions def props(token:Option[String]):Props...