Implementation

First of all, let's have a look at the API we want and its usage:

val system = ActorSystem("PiSystem")val root = system actorOf Worker.workerProps(root ? Job(new URL("http://mvnrepository.com/"), 1)).onSuccess {  case Result(res) =>  println("Crawling finished successfully")  println(res.take(10).mkString("\n"))  println(res.size)}

In the preceding code, you can see the main method of the parallelized actor application. As you can see, we create an actor system and a root-level worker actor. The idea is to represent all of the processing actors as a single class, Worker. The job of a single worker is to process a single URL and spawn additional workers to process the links extracted from it.

Next, you can see an example of querying ...

Get Mastering Functional Programming 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.