Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[writing-async-app-in-scala-part-3] direct executor context usage
def rpcCall: Future[String]
def daoCall(id: String): Future[Int]
def extractId(idStr: String): Future[String]
def convertDbValue(value: Int): Future[Int]
import directExecutionContext
for {
idStr <- rpcCall
id <- extractId(idStr) // executed in RPC execution context
valueFromDb <- daoCall(id)
value <- convertDbValue(valueFromDb) // executed in DAO execution context
} yield value // executed in DAO execution context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment