mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 03:28:44 +00:00
update up to kotlin 1.9.20-Beta2
This commit is contained in:
parent
834d60ff16
commit
3f9a4e95a3
@ -1,6 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kotlin = "1.9.10"
|
kotlin = "1.9.20-Beta2"
|
||||||
kotlin-serialization = "1.6.0"
|
kotlin-serialization = "1.6.0"
|
||||||
kotlin-coroutines = "1.7.3"
|
kotlin-coroutines = "1.7.3"
|
||||||
|
|
||||||
|
@ -14,7 +14,18 @@ import kotlinx.serialization.json.Json
|
|||||||
* * On JS, JVM and MingwX64 platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor]
|
* * On JS, JVM and MingwX64 platforms it is [dev.inmo.tgbotapi.bot.ktor.base.DefaultKtorRequestsExecutor]
|
||||||
* * On LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor]
|
* * On LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor]
|
||||||
*/
|
*/
|
||||||
expect class KtorRequestsExecutor (
|
expect class KtorRequestsExecutor internal constructor(
|
||||||
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
|
client: HttpClient,
|
||||||
|
callsFactories: List<KtorCallFactory>,
|
||||||
|
excludeDefaultFactories: Boolean,
|
||||||
|
requestsLimiter: RequestLimiter,
|
||||||
|
jsonFormatter: Json,
|
||||||
|
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||||
|
diff: Unit // just a diff property to know where constructor and where calling function with defaults
|
||||||
|
) : BaseRequestsExecutor
|
||||||
|
|
||||||
|
fun KtorRequestsExecutor(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient(),
|
client: HttpClient = HttpClient(),
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory> = emptyList(),
|
||||||
@ -22,4 +33,13 @@ expect class KtorRequestsExecutor (
|
|||||||
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
||||||
jsonFormatter: Json = nonstrictJsonFormat,
|
jsonFormatter: Json = nonstrictJsonFormat,
|
||||||
pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
||||||
) : BaseRequestsExecutor
|
) = KtorRequestsExecutor(
|
||||||
|
telegramAPIUrlsKeeper = telegramAPIUrlsKeeper,
|
||||||
|
client = client,
|
||||||
|
callsFactories = callsFactories,
|
||||||
|
excludeDefaultFactories = excludeDefaultFactories,
|
||||||
|
requestsLimiter = requestsLimiter,
|
||||||
|
jsonFormatter = jsonFormatter,
|
||||||
|
pipelineStepsHolder = pipelineStepsHolder,
|
||||||
|
diff = kotlin.Unit
|
||||||
|
)
|
||||||
|
@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.bot.exceptions.CommonBotException
|
|||||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories
|
import dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
@ -19,14 +20,15 @@ import io.ktor.client.plugins.*
|
|||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
class DefaultKtorRequestsExecutor(
|
class DefaultKtorRequestsExecutor internal constructor(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient = HttpClient(),
|
client: HttpClient,
|
||||||
callsFactories: List<KtorCallFactory> = emptyList(),
|
callsFactories: List<KtorCallFactory>,
|
||||||
excludeDefaultFactories: Boolean = false,
|
excludeDefaultFactories: Boolean,
|
||||||
private val requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
private val requestsLimiter: RequestLimiter,
|
||||||
private val jsonFormatter: Json = nonstrictJsonFormat,
|
private val jsonFormatter: Json,
|
||||||
private val pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
private val pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||||
|
diff: Unit
|
||||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||||
if (!excludeDefaultFactories) {
|
if (!excludeDefaultFactories) {
|
||||||
|
@ -4,9 +4,12 @@ import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
|||||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||||
|
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor
|
||||||
|
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||||
|
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
@ -55,7 +58,8 @@ class MultipleClientKtorRequestsExecutor (
|
|||||||
excludeDefaultFactories,
|
excludeDefaultFactories,
|
||||||
requestsLimiter,
|
requestsLimiter,
|
||||||
jsonFormatter,
|
jsonFormatter,
|
||||||
pipelineStepsHolder
|
pipelineStepsHolder,
|
||||||
|
Unit
|
||||||
)
|
)
|
||||||
}.toSet()
|
}.toSet()
|
||||||
private val freeClients = MutableStateFlow<Set<DefaultKtorRequestsExecutor>>(requestExecutors)
|
private val freeClients = MutableStateFlow<Set<DefaultKtorRequestsExecutor>>(requestExecutors)
|
||||||
@ -68,14 +72,15 @@ class MultipleClientKtorRequestsExecutor (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
internal constructor(
|
||||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
callsFactories: List<KtorCallFactory>,
|
callsFactories: List<KtorCallFactory>,
|
||||||
excludeDefaultFactories: Boolean,
|
excludeDefaultFactories: Boolean,
|
||||||
requestsLimiter: RequestLimiter,
|
requestsLimiter: RequestLimiter,
|
||||||
jsonFormatter: Json,
|
jsonFormatter: Json,
|
||||||
pipelineStepsHolder: KtorPipelineStepsHolder
|
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||||
|
diff: Unit
|
||||||
) : this(
|
) : this(
|
||||||
telegramAPIUrlsKeeper,
|
telegramAPIUrlsKeeper,
|
||||||
callsFactories,
|
callsFactories,
|
||||||
|
Loading…
Reference in New Issue
Block a user