Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created May 25, 2020 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkomanov/7cc7526582f62bf42f61b00e6a86f21b to your computer and use it in GitHub Desktop.
Save dkomanov/7cc7526582f62bf42f61b00e6a86f21b to your computer and use it in GitHub Desktop.
[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