Created
May 25, 2020 16:19
-
-
Save dkomanov/1b8352bf30afccef525f5d527bcd5320 to your computer and use it in GitHub Desktop.
[writing-async-app-in-scala-part-3] blocking dao 1
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
implicit val blockingExecutionContext = | |
ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(50)) | |
class MyDao(jdbcTemplate: JdbcTemplate)(implicit ec: ExecutionContext) { | |
def get(id: String): Future[Option[RichDomainObject]] = | |
Future(getBlocking(id)) | |
private def getBlocking(id: String): Option[RichDomainObject] = | |
jdbcTemplate.queryForObject( | |
"SELECT blob FROM table WHERE id = ?", | |
Array(id), | |
rs => parseJson(rs.getString(1)) | |
) | |
private def parseJson(s: String): RichDomainObject = ??? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment