just commit

This commit is contained in:
2020-07-30 15:28:11 +06:00
parent 981a354441
commit 3795b85827
29 changed files with 429 additions and 47 deletions

View File

@@ -31,14 +31,14 @@ repositories {
}
dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "org.jetbrains.exposed:exposed-core:$exposed_version"
api "org.jetbrains.exposed:exposed-jdbc:$exposed_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "com.insanusmokrassar:postssystem.core:$core_version"
api "com.insanusmokrassar:postssystem.exposed.commons:$core_version"
} else {
implementation project(":postssystem.core")
api project(":postssystem.core")
api project(":postssystem.exposed.commons")
}
testImplementation "org.xerial:sqlite-jdbc:$test_sqlite_version"

View File

@@ -1,3 +0,0 @@
package com.insanusmokrassar.postssystem.core.exposed
internal const val ChannelDefaultSize = 64

View File

@@ -6,6 +6,7 @@ import com.insanusmokrassar.postssystem.core.exposed.content.*
import com.insanusmokrassar.postssystem.core.utils.generateContentId
import com.insanusmokrassar.postssystem.core.utils.pagination.*
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import org.jetbrains.exposed.sql.*
@@ -33,8 +34,8 @@ private class ContentAPIDatabaseTable(
}
}
private val contentCreatedBroadcastChannel = BroadcastChannel<RegisteredContent>(ChannelDefaultSize)
private val contentDeletedBroadcastChannel = BroadcastChannel<RegisteredContent>(ChannelDefaultSize)
private val contentCreatedBroadcastChannel = BroadcastChannel<RegisteredContent>(Channel.BUFFERED)
private val contentDeletedBroadcastChannel = BroadcastChannel<RegisteredContent>(Channel.BUFFERED)
override val contentCreatedFlow: Flow<RegisteredContent> = contentCreatedBroadcastChannel.asFlow()
override val contentDeletedFlow: Flow<RegisteredContent> = contentDeletedBroadcastChannel.asFlow()

View File

@@ -2,11 +2,12 @@ package com.insanusmokrassar.postssystem.core.exposed
import com.insanusmokrassar.postssystem.core.content.ContentId
import com.insanusmokrassar.postssystem.core.post.*
import com.insanusmokrassar.postssystem.core.post.api.PostsAPI
import com.insanusmokrassar.postssystem.core.post.repo.PostsRepo
import com.insanusmokrassar.postssystem.core.utils.generatePostId
import com.insanusmokrassar.postssystem.core.utils.pagination.*
import com.soywiz.klock.*
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import org.jetbrains.exposed.sql.*
@@ -58,9 +59,9 @@ private class PostsAPIContentRelations(
private val dateTimeFormat = DateFormat("EEE, dd MMM yyyy HH:mm:ss z")
private class PostsAPIDatabaseTable(
private class PostsRepoDatabaseTable(
private val database: Database
) : PostsAPI, Table() {
) : PostsRepo, Table() {
private val contentsTable = PostsAPIContentRelations(database)
private val idColumn = text("postId")
@@ -69,18 +70,18 @@ private class PostsAPIDatabaseTable(
)
private val postCreatedBroadcastChannel = BroadcastChannel<RegisteredPost>(ChannelDefaultSize)
private val postCreatedBroadcastChannel = BroadcastChannel<RegisteredPost>(Channel.BUFFERED)
override val postCreatedFlow: Flow<RegisteredPost> = postCreatedBroadcastChannel.asFlow()
private val postDeletedBroadcastChannel = BroadcastChannel<RegisteredPost>(ChannelDefaultSize)
private val postDeletedBroadcastChannel = BroadcastChannel<RegisteredPost>(Channel.BUFFERED)
override val postDeletedFlow: Flow<RegisteredPost> = postDeletedBroadcastChannel.asFlow()
private val postUpdatedBroadcastChannel = BroadcastChannel<RegisteredPost>(ChannelDefaultSize)
private val postUpdatedBroadcastChannel = BroadcastChannel<RegisteredPost>(Channel.BUFFERED)
override val postUpdatedFlow: Flow<RegisteredPost> = postUpdatedBroadcastChannel.asFlow()
init {
transaction(database) {
SchemaUtils.createMissingTablesAndColumns(this@PostsAPIDatabaseTable)
SchemaUtils.createMissingTablesAndColumns(this@PostsRepoDatabaseTable)
}
}
@@ -170,6 +171,6 @@ private class PostsAPIDatabaseTable(
}
class ExposedPostsAPI (
class ExposedPostsRepo (
database: Database
) : PostsAPI by PostsAPIDatabaseTable(database)
) : PostsRepo by PostsRepoDatabaseTable(database)

View File

@@ -8,12 +8,12 @@ import java.io.File
import java.sql.Connection
import kotlin.test.*
class ExposedPostsAPICommonTests {
class ExposedPostsRepoCommonTests {
private val tempFolder = System.getProperty("java.io.tmpdir")!!
private val numberOfDatabases = 8
private lateinit var databaseFiles: List<File>
private lateinit var apis: List<ExposedPostsAPI>
private lateinit var apis: List<ExposedPostsRepo>
@BeforeTest
fun prepare() {
@@ -24,7 +24,7 @@ class ExposedPostsAPICommonTests {
val database = Database.connect("jdbc:sqlite:${it.absolutePath}").also {
it.transactionManager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
}
ExposedPostsAPI(
ExposedPostsRepo(
database
)
}