I am using Doobie and in the examples that I found, it uses unsafeRunSync
, like:
sql"select name from country"
.query[String] // Query0[String]
.to[List] // ConnectionIO[List[String]]
.transact(xa) // IO[List[String]]
.unsafeRunSync // List[String]
.take(5) // List[String]
.foreach(println)
Under the hood, this function is implemented as follows:
final def unsafeRunSync(): A = unsafeRunTimed(Duration.Inf).get
In the docs, I found that "Please note that this function is intended for testing; it should never appear in your mainline production code!". I wonder if it is okay then to use unsafeRunSync
in production if it uses this function under the hood?
Also, how do I put a timeout on the execution if not with unsafeRunTimed
?