Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[writing-async-app-in-scala-part-2] RPC with caching 2
val handlers: List[HttpRequest => Future[Option[Int]]] = List(
r => handleFromHadoop(r).map(Some.apply)
def handle(r: HttpRequest): Future[Int] = {
executeLazily( => () => handler(r)))
.map(_.getOrElse(throw new IllegalStateException("Hadoop should always return Some!")))
def executeLazily(list: List[() => Future[Option[Int]]]): Future[Option[Int]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment