From c13e3b996cc4251ad0993ad013c607801e289622 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 11 Nov 2019 15:14:40 +0600 Subject: [PATCH] Revert "now all transaction in database realisation are working in IO thread" This reverts commit b4c694aea9e540ec851a53d0425900ecd942341e. --- .../postssystem/core/exposed/ExposedContentAPI.kt | 8 ++------ .../postssystem/core/exposed/ExposedPostsAPI.kt | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt b/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt index 3c60adc7..938db144 100644 --- a/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt +++ b/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedContentAPI.kt @@ -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 transaction(noinline body: Transaction.() -> T): T = withContext(Dispatchers.IO) { - database.transaction(body) - } + private inline fun transaction(noinline body: Transaction.() -> T): T = database.transaction(body) init { - database.transaction { + transaction { SchemaUtils.createMissingTablesAndColumns(this@ContentAPIDatabaseTable) } } diff --git a/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt b/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt index 29875c7c..ac50e1c7 100644 --- a/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt +++ b/exposed/src/main/kotlin/com/insanusmokrassar/postssystem/core/exposed/ExposedPostsAPI.kt @@ -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(Channel.BUFFERED) override val postUpdatedFlow: Flow = postUpdatedBroadcastChannel.asFlow() - private suspend inline fun transaction(noinline body: Transaction.() -> T): T = withContext(Dispatchers.IO) { - database.transaction(body) - } + private inline fun transaction(noinline body: Transaction.() -> T): T = database.transaction(body) init { - database.transaction { + transaction { SchemaUtils.createMissingTablesAndColumns(this@PostsAPIDatabaseTable) } }