mirror of
https://github.com/InsanusMokrassar/SauceNaoAPI.git
synced 2024-11-26 08:18:42 +00:00
fill changelog and improve RequestQoutaManager API
This commit is contained in:
parent
9c25b08296
commit
cf8ec46513
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
## 0.13.0
|
## 0.13.0
|
||||||
|
|
||||||
|
* Versions:
|
||||||
|
* `Kotlin`: `1.7.20` -> `1.7.22`
|
||||||
|
* `Serialization`: `1.4.0` -> `1.4.1`
|
||||||
|
* `Klock`: `3.2.0` -> `3.4.0`
|
||||||
|
* `Ktor`: `2.1.2` -> `2.2.1`
|
||||||
|
* Now it is possible to subscribe onto API limits changes
|
||||||
|
|
||||||
## 0.12.2
|
## 0.12.2
|
||||||
|
|
||||||
* Versions:
|
* Versions:
|
||||||
|
@ -10,6 +10,7 @@ import dev.inmo.saucenaoapi.models.LimitsState
|
|||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.merge
|
import kotlinx.coroutines.flow.merge
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@ -18,15 +19,19 @@ import kotlin.math.min
|
|||||||
internal class RequestQuotaManager (
|
internal class RequestQuotaManager (
|
||||||
scope: CoroutineScope
|
scope: CoroutineScope
|
||||||
) {
|
) {
|
||||||
private val longQuotaFlow = MutableStateFlow(1)
|
private val _longQuotaFlow = MutableStateFlow(1)
|
||||||
private val shortQuotaFlow = MutableStateFlow(1)
|
private val _shortQuotaFlow = MutableStateFlow(1)
|
||||||
private val longMaxQuotaFlow = MutableStateFlow(1)
|
private val _longMaxQuotaFlow = MutableStateFlow(1)
|
||||||
private val shortMaxQuotaFlow = MutableStateFlow(1)
|
private val _shortMaxQuotaFlow = MutableStateFlow(1)
|
||||||
private var longQuota by longQuotaFlow::value
|
private var longQuota by _longQuotaFlow::value
|
||||||
private var shortQuota by shortQuotaFlow::value
|
private var shortQuota by _shortQuotaFlow::value
|
||||||
private var longMaxQuota by longMaxQuotaFlow::value
|
private var longMaxQuota by _longMaxQuotaFlow::value
|
||||||
private var shortMaxQuota by shortMaxQuotaFlow::value
|
private var shortMaxQuota by _shortMaxQuotaFlow::value
|
||||||
|
|
||||||
|
val longQuotaFlow = _longQuotaFlow.asStateFlow()
|
||||||
|
val shortQuotaFlow = _shortQuotaFlow.asStateFlow()
|
||||||
|
val longMaxQuotaFlow = _longMaxQuotaFlow.asStateFlow()
|
||||||
|
val shortMaxQuotaFlow = _shortMaxQuotaFlow.asStateFlow()
|
||||||
val limitsStateFlow = merge(
|
val limitsStateFlow = merge(
|
||||||
longQuotaFlow, shortQuotaFlow, longMaxQuotaFlow, shortMaxQuotaFlow
|
longQuotaFlow, shortQuotaFlow, longMaxQuotaFlow, shortMaxQuotaFlow
|
||||||
).map { _ ->
|
).map { _ ->
|
||||||
|
Loading…
Reference in New Issue
Block a user