Fred Friis
06/14/2023, 8:26 PMsuspend fun <T> queryForList(arguments): Either<DbError, List<T>> {
return Either
.catch {
runInterruptible(<http://Dispatchers.IO|Dispatchers.IO>) {
jdbcTemplate.queryForStream(sql, args, mapper).use { it.toList() }
}
}.mapLeft { DbError.TalkToDbError() }
}
suspend fun <T> queryForList(arguments): Either<DbError, List<T>> {
return runInterruptible(<http://Dispatchers.IO|Dispatchers.IO>) {
Either
.catch { jdbcTemplate.queryForStream(sql, args, mapper).use { it.toList() } }
.mapLeft { DbError.TalkToDbError() }
}
}
or are they identical in practice?
to be clear, the suspend fun type signature ends up the same, I guess I'm wondering if there's any difference in execution eg if the parent coroutine calling this db call coroutine gets cancelled/interrupted and it tries to cancel the child etcsimon.vergauwen
06/14/2023, 9:52 PMrunInterruptible
does something completely independent and calls and returns immediately.Fred Friis
06/14/2023, 9:57 PMsimon.vergauwen
06/14/2023, 9:58 PM