blob: 44f177c348532c269e4c1a7ada639f5d89133ee9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package xyz.driver.pdsuicommon.db
import xyz.driver.pdsuicommon.logging._
import scala.concurrent.Future
import scala.util.{Failure, Success, Try}
class JdbcDbIo(sqlContext: TransactionalContext) extends DbIo with PhiLogging {
override def runAsync[T](f: => T): Future[T] = {
Future(f)(sqlContext.executionContext)
}
override def runAsyncTx[T](f: => T): Future[T] = {
import sqlContext.executionContext
Future(sqlContext.transaction(f)).andThen {
case Failure(e) => logger.error(phi"Can't run a transaction: $e")
}
}
override def runSyncTx[T](f: => T): Unit = {
Try(sqlContext.transaction(f)) match {
case Success(_) =>
case Failure(e) => logger.error(phi"Can't run a transaction: $e")
}
}
}
|