From 8f522509c05590d74ef72be743d0a443b9fd7ae5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 14 Oct 2020 22:29:03 +0600 Subject: [PATCH] renames in keyvalue --- CHANGELOG.md | 2 ++ .../inmo/micro_utils/repos/StandartKeyValueRepo.kt | 6 +++--- .../repos/pagination/KeyValuePaginationExtensions.kt | 6 +++--- .../keyvalue/AbstractExposedReadKeyValueRepo.kt | 4 ++-- .../dev/inmo/micro_utils/repos/MapKeyValueRepo.kt | 8 ++++---- ...eyValueRepo.kt => KtorReadStandardKeyValueRepo.kt} | 11 +++++++---- .../ktor/client/key_value/KtorStandartKeyValueRepo.kt | 8 ++++---- ...yValueRepo.kt => KtorWriteStandardKeyValueRepo.kt} | 11 +++++++---- .../server/key_value/KtorStandartReadKeyValueRepo.kt | 4 ++-- .../server/key_value/KtorStandartWriteKeyValueRepo.kt | 4 ++-- 10 files changed, 36 insertions(+), 28 deletions(-) rename repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/{KtorStandartReadKeyValueRepo.kt => KtorReadStandardKeyValueRepo.kt} (85%) rename repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/{KtorStandartWriteKeyValueRepo.kt => KtorWriteStandardKeyValueRepo.kt} (80%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a00799ecb03..6cf5619712d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ Inited :) * `Common` * Interfaces related to `OneToManyKeyValueRepo` were renamed with convenience to `Read`/`Write` modifier before name * All subclasses were renamed + * Interfaces related to `StandartKeyValueRepo` were renamed with convenience to `Read`/`Write` modifier before name + * All subclasses were renamed * Extensions `doForAll` and `getAll` were added for all current types of repos: * `ReadStandardCRUDRepo` * `ReadStandardKeyValueRepo` diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt index 6cc2c6a03f7..a2666571db6 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/StandartKeyValueRepo.kt @@ -4,7 +4,7 @@ import dev.inmo.micro_utils.pagination.Pagination import dev.inmo.micro_utils.pagination.PaginationResult import kotlinx.coroutines.flow.Flow -interface StandardReadKeyValueRepo : Repo { +interface ReadStandardKeyValueRepo : Repo { suspend fun get(k: Key): Value? suspend fun values(pagination: Pagination, reversed: Boolean = false): PaginationResult suspend fun keys(pagination: Pagination, reversed: Boolean = false): PaginationResult @@ -12,7 +12,7 @@ interface StandardReadKeyValueRepo : Repo { suspend fun count(): Long } -interface StandardWriteKeyValueRepo : Repo { +interface WriteStandardKeyValueRepo : Repo { val onNewValue: Flow> val onValueRemoved: Flow @@ -20,4 +20,4 @@ interface StandardWriteKeyValueRepo : Repo { suspend fun unset(k: Key) } -interface StandardKeyValueRepo : StandardReadKeyValueRepo, StandardWriteKeyValueRepo \ No newline at end of file +interface StandardKeyValueRepo : ReadStandardKeyValueRepo, WriteStandardKeyValueRepo \ No newline at end of file diff --git a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/KeyValuePaginationExtensions.kt b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/KeyValuePaginationExtensions.kt index 8bd84afdce0..4442571948c 100644 --- a/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/KeyValuePaginationExtensions.kt +++ b/repos/common/src/commonMain/kotlin/dev/inmo/micro_utils/repos/pagination/KeyValuePaginationExtensions.kt @@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.pagination import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.* -suspend inline fun > REPO.doForAll( +suspend inline fun > REPO.doForAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") methodCaller: suspend REPO.(Pagination) -> PaginationResult, block: (List>) -> Unit @@ -15,11 +15,11 @@ suspend inline fun > REP } } -suspend inline fun > REPO.doForAll( +suspend inline fun > REPO.doForAll( block: (List>) -> Unit ) = doForAll({ keys(it, false) }, block) -suspend inline fun > REPO.getAll( +suspend inline fun > REPO.getAll( @Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE") methodCaller: suspend REPO.(Pagination) -> PaginationResult ): List> { diff --git a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt index 83ca592d8ee..867f7439cd8 100644 --- a/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt +++ b/repos/exposed/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/exposed/keyvalue/AbstractExposedReadKeyValueRepo.kt @@ -1,7 +1,7 @@ package dev.inmo.micro_utils.repos.exposed.keyvalue import dev.inmo.micro_utils.pagination.* -import dev.inmo.micro_utils.repos.StandardReadKeyValueRepo +import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.transactions.transaction @@ -9,7 +9,7 @@ abstract class AbstractExposedReadKeyValueRepo( protected val database: Database, protected val keyColumn: Column, protected val valueColumn: Column -) : StandardReadKeyValueRepo, Table() { +) : ReadStandardKeyValueRepo, Table() { override val primaryKey: PrimaryKey = PrimaryKey(keyColumn, valueColumn) override suspend fun get(k: Key): Value? = transaction(database) { diff --git a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValueRepo.kt b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValueRepo.kt index ef86cf9ec7a..506033e6c70 100644 --- a/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValueRepo.kt +++ b/repos/inmemory/src/commonMain/kotlin/dev/inmo/micro_utils/repos/MapKeyValueRepo.kt @@ -6,7 +6,7 @@ import kotlinx.coroutines.flow.Flow class ReadMapKeyValueRepo( private val map: Map = emptyMap() -) : StandardReadKeyValueRepo { +) : ReadStandardKeyValueRepo { override suspend fun get(k: Key): Value? = map[k] override suspend fun values( @@ -47,7 +47,7 @@ class ReadMapKeyValueRepo( class WriteMapKeyValueRepo( private val map: MutableMap = mutableMapOf() -) : StandardWriteKeyValueRepo { +) : WriteStandardKeyValueRepo { private val _onNewValue: BroadcastFlow> = BroadcastFlow() override val onNewValue: Flow> get() = _onNewValue @@ -68,7 +68,7 @@ class WriteMapKeyValueRepo( class MapKeyValueRepo( private val map: MutableMap = mutableMapOf() ) : StandardKeyValueRepo, - StandardReadKeyValueRepo by ReadMapKeyValueRepo(map), - StandardWriteKeyValueRepo by WriteMapKeyValueRepo(map) + ReadStandardKeyValueRepo by ReadMapKeyValueRepo(map), + WriteStandardKeyValueRepo by WriteMapKeyValueRepo(map) fun MutableMap.asKeyValueRepo(): StandardKeyValueRepo = MapKeyValueRepo(this) diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartReadKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorReadStandardKeyValueRepo.kt similarity index 85% rename from repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartReadKeyValueRepo.kt rename to repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorReadStandardKeyValueRepo.kt index 588768223d3..f7c0af2e256 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartReadKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorReadStandardKeyValueRepo.kt @@ -6,19 +6,19 @@ import dev.inmo.micro_utils.ktor.common.buildStandardUrl import dev.inmo.micro_utils.pagination.Pagination import dev.inmo.micro_utils.pagination.PaginationResult import dev.inmo.micro_utils.pagination.asUrlQueryParts -import dev.inmo.micro_utils.repos.StandardReadKeyValueRepo +import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo import dev.inmo.micro_utils.repos.ktor.common.key_value.* import io.ktor.client.* import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.serializer -class KtorStandartReadKeyValueRepo ( +class KtorReadStandardKeyValueRepo ( private var baseUrl: String, private var client: HttpClient = HttpClient(), private var keySerializer: KSerializer, private var valueSerializer: KSerializer, private var valueNullableSerializer: KSerializer, -) : StandardReadKeyValueRepo { +) : ReadStandardKeyValueRepo { override suspend fun get(k: Key): Value? = client.uniget( buildStandardUrl( baseUrl, @@ -70,4 +70,7 @@ class KtorStandartReadKeyValueRepo ( ), Long.serializer() ) -} \ No newline at end of file +} + +@Deprecated("Renamed", ReplaceWith("KtorReadStandardKeyValueRepo", "dev.inmo.micro_utils.repos.ktor.client.key_value.KtorReadStandardKeyValueRepo")) +typealias KtorStandartReadKeyValueRepo = KtorReadStandardKeyValueRepo diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartKeyValueRepo.kt index d81700e52f9..9c7164ab49f 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartKeyValueRepo.kt @@ -1,8 +1,8 @@ package dev.inmo.micro_utils.repos.ktor.client.key_value import dev.inmo.micro_utils.repos.StandardKeyValueRepo -import dev.inmo.micro_utils.repos.StandardReadKeyValueRepo -import dev.inmo.micro_utils.repos.StandardWriteKeyValueRepo +import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo +import dev.inmo.micro_utils.repos.WriteStandardKeyValueRepo import io.ktor.client.* import kotlinx.serialization.KSerializer @@ -14,14 +14,14 @@ class KtorStandartKeyValueRepo ( valueSerializer: KSerializer, valueNullableSerializer: KSerializer ) : StandardKeyValueRepo, - StandardReadKeyValueRepo by KtorStandartReadKeyValueRepo( + ReadStandardKeyValueRepo by KtorReadStandardKeyValueRepo( "$baseUrl/$baseSubpart", client, keySerializer, valueSerializer, valueNullableSerializer ), - StandardWriteKeyValueRepo by KtorStandartWriteKeyValueRepo( + WriteStandardKeyValueRepo by KtorWriteStandardKeyValueRepo( "$baseUrl/$baseSubpart", client, keySerializer, diff --git a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartWriteKeyValueRepo.kt b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt similarity index 80% rename from repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartWriteKeyValueRepo.kt rename to repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt index e8f11ecebc7..043f21155db 100644 --- a/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorStandartWriteKeyValueRepo.kt +++ b/repos/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/repos/ktor/client/key_value/KtorWriteStandardKeyValueRepo.kt @@ -4,7 +4,7 @@ import dev.inmo.micro_utils.ktor.client.BodyPair import dev.inmo.micro_utils.ktor.client.createStandardWebsocketFlow import dev.inmo.micro_utils.ktor.client.unipost import dev.inmo.micro_utils.ktor.common.buildStandardUrl -import dev.inmo.micro_utils.repos.StandardWriteKeyValueRepo +import dev.inmo.micro_utils.repos.WriteStandardKeyValueRepo import dev.inmo.micro_utils.repos.ktor.common.key_value.* import io.ktor.client.* import kotlinx.coroutines.flow.Flow @@ -12,12 +12,12 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.PairSerializer import kotlinx.serialization.builtins.serializer -class KtorStandartWriteKeyValueRepo ( +class KtorWriteStandardKeyValueRepo ( private var baseUrl: String, private var client: HttpClient = HttpClient(), private var keySerializer: KSerializer, private var valueSerializer: KSerializer, -) : StandardWriteKeyValueRepo { +) : WriteStandardKeyValueRepo { override val onNewValue: Flow> = client.createStandardWebsocketFlow( buildStandardUrl(baseUrl, onNewValueRoute), deserializer = PairSerializer(keySerializer, valueSerializer) @@ -45,4 +45,7 @@ class KtorStandartWriteKeyValueRepo ( BodyPair(keySerializer, k), Unit.serializer() ) -} \ No newline at end of file +} + +@Deprecated("Renamed", ReplaceWith("KtorWriteStandardKeyValueRepo", "dev.inmo.micro_utils.repos.ktor.client.key_value.KtorWriteStandardKeyValueRepo")) +typealias KtorStandartWriteKeyValueRepo = KtorWriteStandardKeyValueRepo diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key_value/KtorStandartReadKeyValueRepo.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key_value/KtorStandartReadKeyValueRepo.kt index d55d3a57b63..ab52eba53f0 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key_value/KtorStandartReadKeyValueRepo.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key_value/KtorStandartReadKeyValueRepo.kt @@ -4,7 +4,7 @@ import dev.inmo.micro_utils.ktor.server.decodeUrlQueryValueOrSendError import dev.inmo.micro_utils.ktor.server.unianswer import dev.inmo.micro_utils.pagination.PaginationResult import dev.inmo.micro_utils.pagination.extractPagination -import dev.inmo.micro_utils.repos.StandardReadKeyValueRepo +import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo import dev.inmo.micro_utils.repos.ktor.common.key_value.* import io.ktor.application.* import io.ktor.routing.* @@ -12,7 +12,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.serializer fun Route.configureReadStandartKeyValueRepoRoutes ( - originalRepo: StandardReadKeyValueRepo, + originalRepo: ReadStandardKeyValueRepo, keySerializer: KSerializer, valueSerializer: KSerializer, valueNullableSerializer: KSerializer, diff --git a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key_value/KtorStandartWriteKeyValueRepo.kt b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key_value/KtorStandartWriteKeyValueRepo.kt index e075249b1bc..249bcbc4741 100644 --- a/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key_value/KtorStandartWriteKeyValueRepo.kt +++ b/repos/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/ktor/server/key_value/KtorStandartWriteKeyValueRepo.kt @@ -2,7 +2,7 @@ package dev.inmo.micro_utils.repos.ktor.server.key_value import dev.inmo.micro_utils.ktor.server.includeWebsocketHandling import dev.inmo.micro_utils.ktor.server.uniload -import dev.inmo.micro_utils.repos.StandardWriteKeyValueRepo +import dev.inmo.micro_utils.repos.WriteStandardKeyValueRepo import dev.inmo.micro_utils.repos.ktor.common.key_value.* import io.ktor.application.* import io.ktor.routing.* @@ -10,7 +10,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.builtins.PairSerializer fun Route.configureWriteStandartKeyValueRepoRoutes ( - originalRepo: StandardWriteKeyValueRepo, + originalRepo: WriteStandardKeyValueRepo, keySerializer: KSerializer, valueSerializer: KSerializer, ) {