several improvements in requests limiters

This commit is contained in:
InsanusMokrassar 2022-12-26 20:49:29 +06:00
parent 5434df1f02
commit 8e64205f53
4 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,7 @@
# TelegramBotAPI changelog
## 4.2.3
## 4.2.2
* `Versions`:

View File

@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true
library_group=dev.inmo
library_version=4.2.2
library_version=4.2.3

View File

@ -36,7 +36,9 @@ class ExceptionsOnlyLimiter(
override suspend fun <T> limit(block: suspend () -> T): T {
while (true) {
lockState.first { !it }
if (lockState.value) {
lockState.first { it == false }
}
var throwable: Throwable? = null
val result = safely({
throwable = when (it) {

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.bot.settings.limiters
object NoLimitsLimiter : RequestLimiter {
override suspend fun <T> limit(block: suspend () -> T): T = block()
}