Skip to content

Instantly share code, notes, and snippets.

@adamw
Created June 14, 2018 14:44
Show Gist options
  • Save adamw/d527f7d9d15ebb2d20d463ff815f538e to your computer and use it in GitHub Desktop.
Save adamw/d527f7d9d15ebb2d20d463ff815f538e to your computer and use it in GitHub Desktop.
private def crawlUrl(url: Url): Unit = {
if (!visitedLinks.contains(url)) {
visitedLinks += url
inProgress += url
actorFor(url.host) ! Crawl(url)
}
}
private def actorFor(host: Host): ActorRef = {
workers.get(host) match {
case None =>
val workerActor = context.actorOf(Props(new Worker(http, parseLinks, self)))
workers += host -> workerActor
workerActor
case Some(ar) => ar
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment