Merge pull request #419 from InsanusMokrassar/0.20.41

0.20.41
This commit is contained in:
InsanusMokrassar 2024-04-01 19:02:13 +06:00 committed by GitHub
commit 4e91649e0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 34 additions and 16 deletions

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## 0.20.41
* `Repos`:
* `Exposed`:
* `AbstractExposedKeyValueRepo`, `ExposedKeyValueRepo`, `AbstractExposedKeyValuesRepo`, `ExposedKeyValuesRepo` got opportunity to setup some part of their flows
## 0.20.40 ## 0.20.40
* `Versions`: * `Versions`:

View File

@ -15,5 +15,5 @@ crypto_js_version=4.1.1
# Project data # Project data
group=dev.inmo group=dev.inmo
version=0.20.40 version=0.20.41
android_code_version=246 android_code_version=247

View File

@ -1,6 +1,7 @@
package dev.inmo.micro_utils.repos.exposed.keyvalue package dev.inmo.micro_utils.repos.exposed.keyvalue
import dev.inmo.micro_utils.repos.KeyValueRepo import dev.inmo.micro_utils.repos.KeyValueRepo
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.statements.* import org.jetbrains.exposed.sql.statements.*
@ -8,13 +9,15 @@ import org.jetbrains.exposed.sql.transactions.transaction
abstract class AbstractExposedKeyValueRepo<Key, Value>( abstract class AbstractExposedKeyValueRepo<Key, Value>(
override val database: Database, override val database: Database,
tableName: String? = null tableName: String? = null,
flowsExtraBufferCapacity: Int = Int.MAX_VALUE,
flowsBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND
) : KeyValueRepo<Key, Value>, AbstractExposedReadKeyValueRepo<Key, Value>( ) : KeyValueRepo<Key, Value>, AbstractExposedReadKeyValueRepo<Key, Value>(
database, database,
tableName tableName
) { ) {
protected val _onNewValue = MutableSharedFlow<Pair<Key, Value>>() protected val _onNewValue = MutableSharedFlow<Pair<Key, Value>>(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
protected val _onValueRemoved = MutableSharedFlow<Key>() protected val _onValueRemoved = MutableSharedFlow<Key>(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
override val onNewValue: Flow<Pair<Key, Value>> = _onNewValue.asSharedFlow() override val onNewValue: Flow<Pair<Key, Value>> = _onNewValue.asSharedFlow()
override val onValueRemoved: Flow<Key> = _onValueRemoved.asSharedFlow() override val onValueRemoved: Flow<Key> = _onValueRemoved.asSharedFlow()

View File

@ -2,6 +2,7 @@ package dev.inmo.micro_utils.repos.exposed.keyvalue
import dev.inmo.micro_utils.repos.KeyValueRepo import dev.inmo.micro_utils.repos.KeyValueRepo
import dev.inmo.micro_utils.repos.exposed.ColumnAllocator import dev.inmo.micro_utils.repos.exposed.ColumnAllocator
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
@ -13,15 +14,17 @@ open class ExposedKeyValueRepo<Key, Value>(
database: Database, database: Database,
keyColumnAllocator: ColumnAllocator<Key>, keyColumnAllocator: ColumnAllocator<Key>,
valueColumnAllocator: ColumnAllocator<Value>, valueColumnAllocator: ColumnAllocator<Value>,
tableName: String? = null tableName: String? = null,
flowsExtraBufferCapacity: Int = Int.MAX_VALUE,
flowsBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND
) : KeyValueRepo<Key, Value>, ExposedReadKeyValueRepo<Key, Value>( ) : KeyValueRepo<Key, Value>, ExposedReadKeyValueRepo<Key, Value>(
database, database,
keyColumnAllocator, keyColumnAllocator,
valueColumnAllocator, valueColumnAllocator,
tableName tableName
) { ) {
protected val _onNewValue = MutableSharedFlow<Pair<Key, Value>>() protected val _onNewValue = MutableSharedFlow<Pair<Key, Value>>(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
protected val _onValueRemoved = MutableSharedFlow<Key>() protected val _onValueRemoved = MutableSharedFlow<Key>(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
override val onNewValue: Flow<Pair<Key, Value>> = _onNewValue.asSharedFlow() override val onNewValue: Flow<Pair<Key, Value>> = _onNewValue.asSharedFlow()
override val onValueRemoved: Flow<Key> = _onValueRemoved.asSharedFlow() override val onValueRemoved: Flow<Key> = _onValueRemoved.asSharedFlow()

View File

@ -1,6 +1,7 @@
package dev.inmo.micro_utils.repos.exposed.onetomany package dev.inmo.micro_utils.repos.exposed.onetomany
import dev.inmo.micro_utils.repos.KeyValuesRepo import dev.inmo.micro_utils.repos.KeyValuesRepo
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.statements.InsertStatement import org.jetbrains.exposed.sql.statements.InsertStatement
@ -8,18 +9,20 @@ import org.jetbrains.exposed.sql.transactions.transaction
abstract class AbstractExposedKeyValuesRepo<Key, Value>( abstract class AbstractExposedKeyValuesRepo<Key, Value>(
override val database: Database, override val database: Database,
tableName: String? = null tableName: String? = null,
flowsExtraBufferCapacity: Int = Int.MAX_VALUE,
flowsBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND
) : KeyValuesRepo<Key, Value>, AbstractExposedReadKeyValuesRepo<Key, Value>( ) : KeyValuesRepo<Key, Value>, AbstractExposedReadKeyValuesRepo<Key, Value>(
database, database,
tableName tableName
) { ) {
protected val _onNewValue: MutableSharedFlow<Pair<Key, Value>> = MutableSharedFlow() protected val _onNewValue: MutableSharedFlow<Pair<Key, Value>> = MutableSharedFlow(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
override val onNewValue: Flow<Pair<Key, Value>> override val onNewValue: Flow<Pair<Key, Value>>
get() = _onNewValue.asSharedFlow() get() = _onNewValue.asSharedFlow()
protected val _onValueRemoved: MutableSharedFlow<Pair<Key, Value>> = MutableSharedFlow() protected val _onValueRemoved: MutableSharedFlow<Pair<Key, Value>> = MutableSharedFlow(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
override val onValueRemoved: Flow<Pair<Key, Value>> override val onValueRemoved: Flow<Pair<Key, Value>>
get() = _onValueRemoved.asSharedFlow() get() = _onValueRemoved.asSharedFlow()
protected val _onDataCleared: MutableSharedFlow<Key> = MutableSharedFlow() protected val _onDataCleared: MutableSharedFlow<Key> = MutableSharedFlow(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
override val onDataCleared: Flow<Key> override val onDataCleared: Flow<Key>
get() = _onDataCleared.asSharedFlow() get() = _onDataCleared.asSharedFlow()

View File

@ -2,6 +2,7 @@ package dev.inmo.micro_utils.repos.exposed.onetomany
import dev.inmo.micro_utils.repos.KeyValuesRepo import dev.inmo.micro_utils.repos.KeyValuesRepo
import dev.inmo.micro_utils.repos.exposed.ColumnAllocator import dev.inmo.micro_utils.repos.exposed.ColumnAllocator
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
@ -13,20 +14,22 @@ open class ExposedKeyValuesRepo<Key, Value>(
database: Database, database: Database,
keyColumnAllocator: ColumnAllocator<Key>, keyColumnAllocator: ColumnAllocator<Key>,
valueColumnAllocator: ColumnAllocator<Value>, valueColumnAllocator: ColumnAllocator<Value>,
tableName: String? = null tableName: String? = null,
flowsExtraBufferCapacity: Int = Int.MAX_VALUE,
flowsBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND
) : KeyValuesRepo<Key, Value>, ExposedReadKeyValuesRepo<Key, Value>( ) : KeyValuesRepo<Key, Value>, ExposedReadKeyValuesRepo<Key, Value>(
database, database,
keyColumnAllocator, keyColumnAllocator,
valueColumnAllocator, valueColumnAllocator,
tableName tableName
) { ) {
protected val _onNewValue: MutableSharedFlow<Pair<Key, Value>> = MutableSharedFlow() protected val _onNewValue: MutableSharedFlow<Pair<Key, Value>> = MutableSharedFlow(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
override val onNewValue: Flow<Pair<Key, Value>> override val onNewValue: Flow<Pair<Key, Value>>
get() = _onNewValue get() = _onNewValue
protected val _onValueRemoved: MutableSharedFlow<Pair<Key, Value>> = MutableSharedFlow() protected val _onValueRemoved: MutableSharedFlow<Pair<Key, Value>> = MutableSharedFlow(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
override val onValueRemoved: Flow<Pair<Key, Value>> override val onValueRemoved: Flow<Pair<Key, Value>>
get() = _onValueRemoved get() = _onValueRemoved
protected val _onDataCleared: MutableSharedFlow<Key> = MutableSharedFlow() protected val _onDataCleared: MutableSharedFlow<Key> = MutableSharedFlow(extraBufferCapacity = flowsExtraBufferCapacity, onBufferOverflow = flowsBufferOverflow)
override val onDataCleared: Flow<Key> override val onDataCleared: Flow<Key>
get() = _onDataCleared get() = _onDataCleared