Created
August 17, 2016 17:14
-
-
Save chessman/8e69b00ad4ebeff500aac0e537ebb8af to your computer and use it in GitHub Desktop.
akka-http with finagle
This file contains 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
import com.twitter.{ util => twitter } | |
path("/") { | |
val result = client1.getThings1 flatMap { things1 => | |
... | |
client2.getThings2 flatMap { things2 => | |
... | |
twitter.Future.join(client3.getThings3, client4.getThings4) | |
} | |
//version 1 | |
Await.result(result.liftToTry, 10.seconds) match { | |
case twitter.Return(result) => complete(result) | |
case twitter.Throw(ex) => complete((StatusCodes.InternalServerError, s"Error: $ex")) | |
} | |
//version 2 | |
onComplete(twitterFutureToScalaFuture(result)) { | |
case Success(result) => complete(result) | |
case Failure(ex) => complete((StatusCodes.InternalServerError, s"Error: $ex")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment