-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
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
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
21 changes: 21 additions & 0 deletions
21
tgkotbot/src/main/kotlin/io/heapy/kotbot/infra/jdbc/TransactionProvider.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.heapy.kotbot.infra.jdbc | ||
|
||
import io.heapy.kotbot.infra.Loom | ||
import kotlinx.coroutines.* | ||
import org.jooq.DSLContext | ||
|
||
class TransactionProvider( | ||
private val dslContext: DSLContext, | ||
) { | ||
suspend fun <R> transaction( | ||
body: suspend TransactionContext.() -> R, | ||
): R { | ||
return withContext(Dispatchers.Loom) { | ||
dslContext.transactionResult { configuration -> | ||
runBlocking { | ||
JooqTransactionContext(configuration.dsl()).body() | ||
} | ||
} | ||
} | ||
} | ||
} |