mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-22 16:47:15 +00:00
repos update
This commit is contained in:
parent
66fc6df3d7
commit
99c0f06b72
@ -5,6 +5,10 @@
|
||||
* `Startup`:
|
||||
* `Launcher`:
|
||||
* Improvements in `StartLauncherPlugin#start` methods
|
||||
* `Repos`:
|
||||
* `Ktor`:
|
||||
* `Client`:
|
||||
* All clients repos got opportunity to customize their flows
|
||||
|
||||
## 0.16.5
|
||||
|
||||
|
@ -1,12 +1,17 @@
|
||||
package dev.inmo.micro_utils.repos.ktor.client.crud
|
||||
|
||||
import dev.inmo.micro_utils.ktor.client.createStandardWebsocketFlow
|
||||
import dev.inmo.micro_utils.ktor.common.*
|
||||
import dev.inmo.micro_utils.pagination.PaginationResult
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import dev.inmo.micro_utils.repos.ktor.common.crud.deletedObjectsIdsFlowRouting
|
||||
import dev.inmo.micro_utils.repos.ktor.common.crud.newObjectsFlowRouting
|
||||
import dev.inmo.micro_utils.repos.ktor.common.crud.updatedObjectsFlowRouting
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.util.reflect.TypeInfo
|
||||
import io.ktor.util.reflect.typeInfo
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.serialization.*
|
||||
|
||||
class KtorCRUDRepoClient<ObjectType, IdType, InputValue> (
|
||||
@ -21,6 +26,15 @@ class KtorCRUDRepoClient<ObjectType, IdType, InputValue> (
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
newObjectsFlow: Flow<ObjectType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, newObjectsFlowRouting),
|
||||
),
|
||||
updatedObjectsFlow: Flow<ObjectType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, updatedObjectsFlowRouting),
|
||||
),
|
||||
deletedObjectsIdsFlow: Flow<IdType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, deletedObjectsIdsFlowRouting),
|
||||
),
|
||||
noinline idSerializer: suspend (IdType) -> String
|
||||
) = KtorCRUDRepoClient(
|
||||
KtorReadCRUDRepoClient(
|
||||
@ -35,7 +49,10 @@ class KtorCRUDRepoClient<ObjectType, IdType, InputValue> (
|
||||
KtorWriteCrudRepoClient<ObjectType, IdType, InputValue>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType
|
||||
contentType,
|
||||
newObjectsFlow,
|
||||
updatedObjectsFlow,
|
||||
deletedObjectsIdsFlow
|
||||
)
|
||||
)
|
||||
|
||||
@ -44,11 +61,23 @@ class KtorCRUDRepoClient<ObjectType, IdType, InputValue> (
|
||||
subpart: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
newObjectsFlow: Flow<ObjectType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, newObjectsFlowRouting),
|
||||
),
|
||||
updatedObjectsFlow: Flow<ObjectType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, updatedObjectsFlowRouting),
|
||||
),
|
||||
deletedObjectsIdsFlow: Flow<IdType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, deletedObjectsIdsFlowRouting),
|
||||
),
|
||||
noinline idSerializer: suspend (IdType) -> String
|
||||
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(
|
||||
buildStandardUrl(baseUrl, subpart),
|
||||
httpClient,
|
||||
contentType,
|
||||
newObjectsFlow,
|
||||
updatedObjectsFlow,
|
||||
deletedObjectsIdsFlow,
|
||||
idSerializer
|
||||
)
|
||||
}
|
||||
@ -80,11 +109,23 @@ inline fun <reified ObjectType, reified IdType, reified InputValue> KtorCRUDRepo
|
||||
subpart: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
newObjectsFlow: Flow<ObjectType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, newObjectsFlowRouting),
|
||||
),
|
||||
updatedObjectsFlow: Flow<ObjectType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, updatedObjectsFlowRouting),
|
||||
),
|
||||
deletedObjectsIdsFlow: Flow<IdType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, deletedObjectsIdsFlowRouting),
|
||||
),
|
||||
noinline idSerializer: suspend (IdType) -> String
|
||||
) = KtorCRUDRepoClient<ObjectType, IdType, InputValue>(
|
||||
buildStandardUrl(baseUrl, subpart),
|
||||
httpClient,
|
||||
contentType,
|
||||
newObjectsFlow,
|
||||
updatedObjectsFlow,
|
||||
deletedObjectsIdsFlow,
|
||||
idSerializer
|
||||
)
|
||||
|
||||
|
@ -53,19 +53,22 @@ class KtorWriteCrudRepoClient<ObjectType, IdType, InputValue> (
|
||||
inline operator fun <reified ObjectType, reified IdType, reified InputValue> invoke(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType
|
||||
contentType: ContentType,
|
||||
newObjectsFlow: Flow<ObjectType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, newObjectsFlowRouting),
|
||||
),
|
||||
updatedObjectsFlow: Flow<ObjectType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, updatedObjectsFlowRouting),
|
||||
),
|
||||
deletedObjectsIdsFlow: Flow<IdType> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, deletedObjectsIdsFlowRouting),
|
||||
),
|
||||
) = KtorWriteCrudRepoClient<ObjectType, IdType, InputValue>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, newObjectsFlowRouting),
|
||||
),
|
||||
httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, updatedObjectsFlowRouting),
|
||||
),
|
||||
httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, deletedObjectsIdsFlowRouting),
|
||||
),
|
||||
newObjectsFlow,
|
||||
updatedObjectsFlow,
|
||||
deletedObjectsIdsFlow,
|
||||
{
|
||||
contentType(contentType)
|
||||
setBody(it)
|
||||
|
@ -1,10 +1,14 @@
|
||||
package dev.inmo.micro_utils.repos.ktor.client.key.value
|
||||
|
||||
import dev.inmo.micro_utils.ktor.client.createStandardWebsocketFlow
|
||||
import dev.inmo.micro_utils.ktor.common.*
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import dev.inmo.micro_utils.repos.ktor.common.key_value.onNewValueRoute
|
||||
import dev.inmo.micro_utils.repos.ktor.common.key_value.onValueRemovedRoute
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.encodeURLQueryComponent
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.serialization.*
|
||||
|
||||
class KtorKeyValueRepoClient<Key, Value> (
|
||||
@ -20,6 +24,12 @@ class KtorKeyValueRepoClient<Key, Value> (
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
noinline idSerializer: suspend (Key) -> String,
|
||||
onNewValue: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
onValueRemoved: Flow<Key> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
noinline valueSerializer: suspend (Value) -> String
|
||||
) = KtorKeyValueRepoClient(
|
||||
KtorReadKeyValueRepoClient(
|
||||
@ -28,7 +38,9 @@ class KtorKeyValueRepoClient<Key, Value> (
|
||||
KtorWriteKeyValueRepoClient(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType
|
||||
contentType,
|
||||
onNewValue,
|
||||
onValueRemoved
|
||||
)
|
||||
)
|
||||
inline operator fun <reified Key, reified Value> invoke(
|
||||
@ -37,12 +49,20 @@ class KtorKeyValueRepoClient<Key, Value> (
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
noinline idSerializer: suspend (Key) -> String,
|
||||
onNewValue: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
onValueRemoved: Flow<Key> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
noinline valueSerializer: suspend (Value) -> String
|
||||
) = KtorKeyValueRepoClient(
|
||||
buildStandardUrl(baseUrl, subpart),
|
||||
httpClient,
|
||||
contentType,
|
||||
idSerializer,
|
||||
onNewValue,
|
||||
onValueRemoved,
|
||||
valueSerializer
|
||||
)
|
||||
}
|
||||
|
@ -60,17 +60,19 @@ class KtorWriteKeyValueRepoClient<Key, Value>(
|
||||
inline operator fun <reified Key, reified Value> invoke(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType
|
||||
contentType: ContentType,
|
||||
onNewValue: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
onValueRemoved: Flow<Key> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
) = KtorWriteKeyValueRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
||||
httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
onNewValue,
|
||||
onValueRemoved,
|
||||
typeInfo<List<Key>>(),
|
||||
typeInfo<List<Value>>(),
|
||||
typeInfo<Map<Key, Value>>()
|
||||
|
@ -1,10 +1,15 @@
|
||||
package dev.inmo.micro_utils.repos.ktor.client.key.values
|
||||
|
||||
import dev.inmo.micro_utils.ktor.client.createStandardWebsocketFlow
|
||||
import dev.inmo.micro_utils.ktor.common.*
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import dev.inmo.micro_utils.repos.ktor.common.one_to_many.onDataClearedRoute
|
||||
import dev.inmo.micro_utils.repos.ktor.common.one_to_many.onNewValueRoute
|
||||
import dev.inmo.micro_utils.repos.ktor.common.one_to_many.onValueRemovedRoute
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.encodeURLQueryComponent
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.serialization.*
|
||||
|
||||
class KtorKeyValuesRepoClient<Key, Value> (
|
||||
@ -20,6 +25,15 @@ class KtorKeyValuesRepoClient<Key, Value> (
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
noinline keySerializer: suspend (Key) -> String,
|
||||
onNewValue: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
onValueRemoved: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
onDataCleared: Flow<Key> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onDataClearedRoute),
|
||||
),
|
||||
noinline valueSerializer: suspend (Value) -> String
|
||||
) = KtorKeyValuesRepoClient(
|
||||
KtorReadKeyValuesRepoClient(
|
||||
@ -32,7 +46,10 @@ class KtorKeyValuesRepoClient<Key, Value> (
|
||||
KtorWriteKeyValuesRepoClient(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType
|
||||
contentType,
|
||||
onNewValue,
|
||||
onValueRemoved,
|
||||
onDataCleared
|
||||
)
|
||||
)
|
||||
inline operator fun <reified Key : Any, reified Value : Any> invoke(
|
||||
@ -41,12 +58,24 @@ class KtorKeyValuesRepoClient<Key, Value> (
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType,
|
||||
noinline keySerializer: suspend (Key) -> String,
|
||||
onNewValue: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
onValueRemoved: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
onDataCleared: Flow<Key> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onDataClearedRoute),
|
||||
),
|
||||
noinline valueSerializer: suspend (Value) -> String
|
||||
) = KtorKeyValuesRepoClient(
|
||||
buildStandardUrl(baseUrl, subpart),
|
||||
httpClient,
|
||||
contentType,
|
||||
keySerializer,
|
||||
onNewValue,
|
||||
onValueRemoved,
|
||||
onDataCleared,
|
||||
valueSerializer
|
||||
)
|
||||
}
|
||||
@ -59,13 +88,25 @@ inline fun <reified Key : Any, reified Value : Any> KtorKeyValuesRepoClient(
|
||||
keySerializer: SerializationStrategy<Key>,
|
||||
valueSerializer: SerializationStrategy<Value>,
|
||||
serialFormat: StringFormat,
|
||||
onNewValue: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
onValueRemoved: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
onDataCleared: Flow<Key> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onDataClearedRoute),
|
||||
),
|
||||
) = KtorKeyValuesRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
||||
{
|
||||
serialFormat.encodeToString(keySerializer, it).encodeURLQueryComponent()
|
||||
}
|
||||
},
|
||||
onNewValue,
|
||||
onValueRemoved,
|
||||
onDataCleared
|
||||
) {
|
||||
serialFormat.encodeToString(valueSerializer, it).encodeURLQueryComponent()
|
||||
}
|
||||
@ -77,13 +118,25 @@ inline fun <reified Key : Any, reified Value : Any> KtorKeyValuesRepoClient(
|
||||
keySerializer: SerializationStrategy<Key>,
|
||||
valueSerializer: SerializationStrategy<Value>,
|
||||
serialFormat: BinaryFormat,
|
||||
onNewValue: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
onValueRemoved: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
onDataCleared: Flow<Key> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onDataClearedRoute),
|
||||
),
|
||||
) = KtorKeyValuesRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
||||
{
|
||||
serialFormat.encodeHex(keySerializer, it)
|
||||
}
|
||||
},
|
||||
onNewValue,
|
||||
onValueRemoved,
|
||||
onDataCleared
|
||||
) {
|
||||
serialFormat.encodeHex(valueSerializer, it)
|
||||
}
|
||||
|
@ -84,20 +84,23 @@ class KtorWriteKeyValuesRepoClient<Key : Any, Value : Any>(
|
||||
inline operator fun <reified Key : Any, reified Value : Any> invoke(
|
||||
baseUrl: String,
|
||||
httpClient: HttpClient,
|
||||
contentType: ContentType
|
||||
contentType: ContentType,
|
||||
onNewValue: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
onValueRemoved: Flow<Pair<Key, Value>> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
onDataCleared: Flow<Key> = httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onDataClearedRoute),
|
||||
),
|
||||
) = KtorWriteKeyValuesRepoClient<Key, Value>(
|
||||
baseUrl,
|
||||
httpClient,
|
||||
contentType,
|
||||
httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onNewValueRoute),
|
||||
),
|
||||
httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onValueRemovedRoute),
|
||||
),
|
||||
httpClient.createStandardWebsocketFlow(
|
||||
buildStandardUrl(baseUrl, onDataClearedRoute),
|
||||
),
|
||||
onNewValue,
|
||||
onValueRemoved,
|
||||
onDataCleared,
|
||||
typeInfo<Key>(),
|
||||
typeInfo<Value>(),
|
||||
typeInfo<Map<Key, List<Value>>>()
|
||||
|
Loading…
Reference in New Issue
Block a user