mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-14 21:09:24 +00:00
renames in key value repos
This commit is contained in:
@@ -7,10 +7,10 @@ import io.ktor.http.ContentType
|
||||
import io.ktor.http.encodeURLQueryComponent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
class KtorStandardKeyValueRepoClient<Key, Value> (
|
||||
readDelegate: ReadStandardKeyValueRepo<Key, Value>,
|
||||
writeDelegate: WriteStandardKeyValueRepo<Key, Value>
|
||||
) : StandardKeyValueRepo<Key, Value> by DelegateBasedStandardKeyValueRepo(
|
||||
class KtorKeyValueRepoClient<Key, Value> (
|
||||
readDelegate: ReadKeyValueRepo<Key, Value>,
|
||||
writeDelegate: WriteKeyValueRepo<Key, Value>
|
||||
) : KeyValueRepo<Key, Value> by DelegateBasedKeyValueRepo(
|
||||
readDelegate,
|
||||
writeDelegate
|
||||
) {
|
||||
@@ -21,11 +21,11 @@ class KtorStandardKeyValueRepoClient<Key, Value> (
|
||||
contentType: ContentType,
|
||||
noinline idSerializer: suspend (Key) -> String,
|
||||
noinline valueSerializer: suspend (Value) -> String
|
||||
) = KtorStandardKeyValueRepoClient(
|
||||
KtorReadStandardKeyValueRepoClient(
|
||||
) = KtorKeyValueRepoClient(
|
||||
KtorReadKeyValueRepoClient(
|
||||
baseUrl, httpClient, contentType, idSerializer, valueSerializer
|
||||
),
|
||||
KtorWriteStandardKeyValueRepoClient(
|
||||
KtorWriteKeyValueRepoClient(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType
|
||||
@@ -38,7 +38,7 @@ class KtorStandardKeyValueRepoClient<Key, Value> (
|
||||
contentType: ContentType,
|
||||
noinline idSerializer: suspend (Key) -> String,
|
||||
noinline valueSerializer: suspend (Value) -> String
|
||||
) = KtorStandardKeyValueRepoClient(
|
||||
) = KtorKeyValueRepoClient(
|
||||
buildStandardUrl(baseUrl, subpart),
|
||||
httpClient,
|
||||
contentType,
|
||||
@@ -48,14 +48,14 @@ class KtorStandardKeyValueRepoClient<Key, Value> (
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified Key, reified Value> KtorStandardKeyValueRepoClient(
|
||||
inline fun <reified Key, reified Value> KtorKeyValueRepoClient(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
idSerializer: SerializationStrategy<Key>,
|
||||
valueSerializer: SerializationStrategy<Value>,
|
||||
serialFormat: StringFormat,
|
||||
) = KtorStandardKeyValueRepoClient<Key, Value>(
|
||||
) = KtorKeyValueRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
||||
@@ -66,14 +66,14 @@ inline fun <reified Key, reified Value> KtorStandardKeyValueRepoClient(
|
||||
serialFormat.encodeToString(valueSerializer, it).encodeURLQueryComponent()
|
||||
}
|
||||
|
||||
inline fun <reified Key, reified Value> KtorStandardKeyValueRepoClient(
|
||||
inline fun <reified Key, reified Value> KtorKeyValueRepoClient(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
idSerializer: SerializationStrategy<Key>,
|
||||
valueSerializer: SerializationStrategy<Value>,
|
||||
serialFormat: BinaryFormat,
|
||||
) = KtorStandardKeyValueRepoClient<Key, Value>(
|
||||
) = KtorKeyValueRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
@@ -2,7 +2,7 @@ package dev.inmo.micro_utils.repos.ktor.client.key_value
|
||||
|
||||
import dev.inmo.micro_utils.ktor.common.*
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.ReadKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.ktor.common.*
|
||||
import dev.inmo.micro_utils.repos.ktor.common.containsRoute
|
||||
import dev.inmo.micro_utils.repos.ktor.common.key_value.*
|
||||
@@ -15,7 +15,7 @@ import io.ktor.util.reflect.TypeInfo
|
||||
import io.ktor.util.reflect.typeInfo
|
||||
import kotlinx.serialization.*
|
||||
|
||||
class KtorReadStandardKeyValueRepoClient<Key, Value>(
|
||||
class KtorReadKeyValueRepoClient<Key, Value>(
|
||||
private val baseUrl: String,
|
||||
private val httpClient: HttpClient,
|
||||
private val contentType: ContentType,
|
||||
@@ -24,7 +24,7 @@ class KtorReadStandardKeyValueRepoClient<Key, Value>(
|
||||
private val paginationResultIdsTypeInfo: TypeInfo,
|
||||
private val idSerializer: suspend (Key) -> String,
|
||||
private val valueSerializer: suspend (Value) -> String
|
||||
) : ReadStandardKeyValueRepo<Key, Value> {
|
||||
) : ReadKeyValueRepo<Key, Value> {
|
||||
override suspend fun get(k: Key): Value? = httpClient.get(
|
||||
buildStandardUrl(
|
||||
baseUrl,
|
||||
@@ -89,13 +89,13 @@ class KtorReadStandardKeyValueRepoClient<Key, Value>(
|
||||
}.body()
|
||||
}
|
||||
|
||||
inline fun <reified Key, reified Value> KtorReadStandardKeyValueRepoClient(
|
||||
inline fun <reified Key, reified Value> KtorReadKeyValueRepoClient(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
noinline idSerializer: suspend (Key) -> String,
|
||||
noinline valueSerializer: suspend (Value) -> String
|
||||
) = KtorReadStandardKeyValueRepoClient<Key, Value>(
|
||||
) = KtorReadKeyValueRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
||||
@@ -106,14 +106,14 @@ inline fun <reified Key, reified Value> KtorReadStandardKeyValueRepoClient(
|
||||
valueSerializer
|
||||
)
|
||||
|
||||
inline fun <reified Key, reified Value> KtorReadStandardKeyValueRepoClient(
|
||||
inline fun <reified Key, reified Value> KtorReadKeyValueRepoClient(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
idsSerializer: KSerializer<Key>,
|
||||
valueSerializer: KSerializer<Value>,
|
||||
serialFormat: StringFormat,
|
||||
contentType: ContentType,
|
||||
) = KtorReadStandardKeyValueRepoClient<Key, Value>(
|
||||
) = KtorReadKeyValueRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
||||
@@ -124,14 +124,14 @@ inline fun <reified Key, reified Value> KtorReadStandardKeyValueRepoClient(
|
||||
serialFormat.encodeToString(valueSerializer, it).encodeURLQueryComponent()
|
||||
}
|
||||
|
||||
inline fun <reified Key, reified Value> KtorReadStandardKeyValueRepoClient(
|
||||
inline fun <reified Key, reified Value> KtorReadKeyValueRepoClient(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
idsSerializer: KSerializer<Key>,
|
||||
valuesSerializer: KSerializer<Value>,
|
||||
serialFormat: BinaryFormat,
|
||||
contentType: ContentType,
|
||||
) = KtorReadStandardKeyValueRepoClient<Key, Value>(
|
||||
) = KtorReadKeyValueRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
@@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.client.key_value
|
||||
import dev.inmo.micro_utils.ktor.client.*
|
||||
import dev.inmo.micro_utils.ktor.common.*
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.repos.ReadStandardKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.ReadKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.ktor.common.*
|
||||
import dev.inmo.micro_utils.repos.ktor.common.containsRoute
|
||||
import dev.inmo.micro_utils.repos.ktor.common.countRoute
|
||||
@@ -14,13 +14,14 @@ import io.ktor.client.HttpClient
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Deprecated("Replaced with KtorReadKeyValueRepoClient")
|
||||
class KtorReadStandardKeyValueRepo<Key, Value> (
|
||||
private val baseUrl: String,
|
||||
private val unifiedRequester: UnifiedRequester,
|
||||
private val keySerializer: KSerializer<Key>,
|
||||
private val valueSerializer: KSerializer<Value>,
|
||||
private val valueNullableSerializer: KSerializer<Value?>
|
||||
) : ReadStandardKeyValueRepo<Key, Value> {
|
||||
) : ReadKeyValueRepo<Key, Value> {
|
||||
constructor(
|
||||
baseUrl: String,
|
||||
client: HttpClient,
|
||||
|
@@ -7,6 +7,7 @@ import dev.inmo.micro_utils.repos.*
|
||||
import io.ktor.client.HttpClient
|
||||
import kotlinx.serialization.*
|
||||
|
||||
@Deprecated("Replaced with KtorKeyValueRepoClient")
|
||||
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE")
|
||||
class KtorStandartKeyValueRepo<K, V> (
|
||||
baseUrl: String,
|
||||
@@ -15,15 +16,15 @@ class KtorStandartKeyValueRepo<K, V> (
|
||||
keySerializer: KSerializer<K>,
|
||||
valueSerializer: KSerializer<V>,
|
||||
valueNullableSerializer: KSerializer<V?>
|
||||
) : StandardKeyValueRepo<K, V>,
|
||||
ReadStandardKeyValueRepo<K, V> by KtorReadStandardKeyValueRepo(
|
||||
) : KeyValueRepo<K, V>,
|
||||
ReadKeyValueRepo<K, V> by KtorReadStandardKeyValueRepo(
|
||||
"$baseUrl/$baseSubpart",
|
||||
unifiedRequester,
|
||||
keySerializer,
|
||||
valueSerializer,
|
||||
valueNullableSerializer
|
||||
),
|
||||
WriteStandardKeyValueRepo<K, V> by KtorWriteStandardKeyValueRepo(
|
||||
WriteKeyValueRepo<K, V> by KtorWriteStandardKeyValueRepo(
|
||||
"$baseUrl/$baseSubpart",
|
||||
unifiedRequester,
|
||||
keySerializer,
|
||||
@@ -38,4 +39,4 @@ class KtorStandartKeyValueRepo<K, V> (
|
||||
valueNullableSerializer: KSerializer<V?>,
|
||||
serialFormat: StandardKtorSerialFormat = standardKtorSerialFormat
|
||||
) : this(baseUrl, baseSubpart, UnifiedRequester(client, serialFormat), keySerializer, valueSerializer, valueNullableSerializer)
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package dev.inmo.micro_utils.repos.ktor.client.key_value
|
||||
import dev.inmo.micro_utils.ktor.client.createStandardWebsocketFlow
|
||||
import dev.inmo.micro_utils.ktor.client.throwOnUnsuccess
|
||||
import dev.inmo.micro_utils.ktor.common.*
|
||||
import dev.inmo.micro_utils.repos.WriteStandardKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.WriteKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.ktor.common.key_value.*
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.request.post
|
||||
@@ -13,7 +13,7 @@ import io.ktor.util.reflect.TypeInfo
|
||||
import io.ktor.util.reflect.typeInfo
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
class KtorWriteStandardKeyValueRepoClient<Key, Value>(
|
||||
class KtorWriteKeyValueRepoClient<Key, Value>(
|
||||
private val baseUrl: String,
|
||||
private val httpClient: HttpClient,
|
||||
private val contentType: ContentType,
|
||||
@@ -22,7 +22,7 @@ class KtorWriteStandardKeyValueRepoClient<Key, Value>(
|
||||
private val idsListTypeInfo: TypeInfo,
|
||||
private val objectsListTypeInfo: TypeInfo,
|
||||
private val idsToObjectsMapTypeInfo: TypeInfo
|
||||
) : WriteStandardKeyValueRepo<Key, Value> {
|
||||
) : WriteKeyValueRepo<Key, Value> {
|
||||
@OptIn(InternalAPI::class)
|
||||
override suspend fun unsetWithValues(toUnset: List<Value>) {
|
||||
httpClient.post(
|
||||
@@ -61,7 +61,7 @@ class KtorWriteStandardKeyValueRepoClient<Key, Value>(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType
|
||||
) = KtorWriteStandardKeyValueRepoClient<Key, Value>(
|
||||
) = KtorWriteKeyValueRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
@@ -2,19 +2,20 @@ package dev.inmo.micro_utils.repos.ktor.client.key_value
|
||||
|
||||
import dev.inmo.micro_utils.ktor.client.*
|
||||
import dev.inmo.micro_utils.ktor.common.*
|
||||
import dev.inmo.micro_utils.repos.WriteStandardKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.WriteKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.ktor.common.key_value.*
|
||||
import io.ktor.client.HttpClient
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.builtins.*
|
||||
|
||||
@Deprecated("Replaced with KtorWriteKeyValueRepoClient")
|
||||
class KtorWriteStandardKeyValueRepo<K, V> (
|
||||
private var baseUrl: String,
|
||||
private var unifiedRequester: UnifiedRequester,
|
||||
private var keySerializer: KSerializer<K>,
|
||||
private var valueSerializer: KSerializer<V>,
|
||||
) : WriteStandardKeyValueRepo<K, V> {
|
||||
) : WriteKeyValueRepo<K, V> {
|
||||
private val keyValueMapSerializer = MapSerializer(keySerializer, valueSerializer)
|
||||
private val keysListSerializer = ListSerializer(keySerializer)
|
||||
private val valuesListSerializer = ListSerializer(valueSerializer)
|
||||
|
Reference in New Issue
Block a user