Skip to content

Instantly share code, notes, and snippets.

@adamw
Created June 14, 2018 15:02
Show Gist options
  • Save adamw/ec0277aa0c95a94316d6556250300af3 to your computer and use it in GitHub Desktop.
Save adamw/ec0277aa0c95a94316d6556250300af3 to your computer and use it in GitHub Desktop.
override def receive: Receive = {
case Crawl(url) =>
urlsPending = urlsPending :+ url
startHttpGetIfPossible()
// ...
}
private def startHttpGetIfPossible(): Unit = {
urlsPending match {
case url +: tail if !getInProgress =>
getInProgress = true
urlsPending = tail
import context.dispatcher
http.get(url).onComplete(r => self ! HttpGetResult(url, r))
case _ =>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment