Created
June 14, 2018 15:02
-
-
Save adamw/ec0277aa0c95a94316d6556250300af3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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