Created
August 7, 2012 19:46
-
-
Save derekwyatt/3288756 to your computer and use it in GitHub Desktop.
Using a Future.sequence() over the Master / Worker remote node pattern
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
| // Downloading could take a while :) | |
| implicit val askTimeout = Timeout(5 minutes) | |
| // Some list of URLs we want to download | |
| val urls = List(url1, ulr2, url3, ..., urlN) | |
| // The Master | |
| val m = system.actorOf(Props[Master], "master") | |
| // Assume Workers are now present | |
| // Get a Future to a bunch of eventual downloaded pages | |
| Future.sequence(urls.map { url => | |
| m ? Download(url) | |
| }) map { pages => | |
| PagesReady(pages) | |
| } pipeTo pageRenderer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment