Revert "now all transaction in database realisation are working in IO thread"

This reverts commit b4c694aea9.
This commit is contained in:
InsanusMokrassar 2019-11-11 15:14:40 +06:00
parent b4c694aea9
commit c13e3b996c
2 changed files with 4 additions and 12 deletions

View File

@ -4,12 +4,10 @@ import com.insanusmokrassar.postssystem.core.content.*
import com.insanusmokrassar.postssystem.core.content.api.ContentAPI
import com.insanusmokrassar.postssystem.core.utils.generateContentId
import com.insanusmokrassar.postssystem.core.utils.pagination.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.withContext
import kotlinx.serialization.json.Json
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.transaction
@ -20,12 +18,10 @@ private class ContentAPIDatabaseTable(
internal val idColumn = text("_id")
internal val dataColumn = text("data")
private suspend inline fun <T> transaction(noinline body: Transaction.() -> T): T = withContext(Dispatchers.IO) {
database.transaction(body)
}
private inline fun <T> transaction(noinline body: Transaction.() -> T): T = database.transaction(body)
init {
database.transaction {
transaction {
SchemaUtils.createMissingTablesAndColumns(this@ContentAPIDatabaseTable)
}
}

View File

@ -6,12 +6,10 @@ import com.insanusmokrassar.postssystem.core.post.api.PostsAPI
import com.insanusmokrassar.postssystem.core.utils.generatePostId
import com.insanusmokrassar.postssystem.core.utils.pagination.*
import com.soywiz.klock.DateTime
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.withContext
import org.jetbrains.exposed.sql.*
private class PostsAPIContentRelations(
@ -79,12 +77,10 @@ private class PostsAPIDatabaseTable(
private val postUpdatedBroadcastChannel = BroadcastChannel<RegisteredPost>(Channel.BUFFERED)
override val postUpdatedFlow: Flow<RegisteredPost> = postUpdatedBroadcastChannel.asFlow()
private suspend inline fun <T> transaction(noinline body: Transaction.() -> T): T = withContext(Dispatchers.IO) {
database.transaction(body)
}
private inline fun <T> transaction(noinline body: Transaction.() -> T): T = database.transaction(body)
init {
database.transaction {
transaction {
SchemaUtils.createMissingTablesAndColumns(this@PostsAPIDatabaseTable)
}
}