From 3f9a4e95a334681bff672b5a28ba6a21e08d4a7e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 21 Sep 2023 15:41:36 +0600 Subject: [PATCH] update up to kotlin 1.9.20-Beta2 --- gradle/libs.versions.toml | 2 +- .../tgbotapi/bot/ktor/KtorRequestsExecutor.kt | 24 +++++++++++++++++-- .../ktor/base/DefaultKtorRequestsExecutor.kt | 16 +++++++------ .../MultipleClientKtorRequestsExecutor.kt | 11 ++++++--- ....kt => KtorRequestsExecutor.actual.jvm.kt} | 0 5 files changed, 40 insertions(+), 13 deletions(-) rename tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/{KtorRequestsExecutor.kt => KtorRequestsExecutor.actual.jvm.kt} (100%) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3a436bb26a..a699df31f7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -kotlin = "1.9.10" +kotlin = "1.9.20-Beta2" kotlin-serialization = "1.6.0" kotlin-coroutines = "1.7.3" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt index b0b1996613..833c420840 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt @@ -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 LinuxX64 it is [dev.inmo.tgbotapi.bot.ktor.base.MultipleClientKtorRequestsExecutor] */ -expect class KtorRequestsExecutor ( +expect class KtorRequestsExecutor internal constructor( + telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, + client: HttpClient, + callsFactories: List, + 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, client: HttpClient = HttpClient(), callsFactories: List = emptyList(), @@ -22,4 +33,13 @@ expect class KtorRequestsExecutor ( requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter, jsonFormatter: Json = nonstrictJsonFormat, pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder -) : BaseRequestsExecutor +) = KtorRequestsExecutor( + telegramAPIUrlsKeeper = telegramAPIUrlsKeeper, + client = client, + callsFactories = callsFactories, + excludeDefaultFactories = excludeDefaultFactories, + requestsLimiter = requestsLimiter, + jsonFormatter = jsonFormatter, + pipelineStepsHolder = pipelineStepsHolder, + diff = kotlin.Unit +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor.kt index 3051931ec2..49ca017764 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor.kt @@ -7,6 +7,7 @@ import dev.inmo.tgbotapi.bot.exceptions.CommonBotException import dev.inmo.tgbotapi.bot.exceptions.newRequestException import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory 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.settings.limiters.ExceptionsOnlyLimiter import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter @@ -19,14 +20,15 @@ import io.ktor.client.plugins.* import io.ktor.client.statement.* import kotlinx.serialization.json.Json -class DefaultKtorRequestsExecutor( +class DefaultKtorRequestsExecutor internal constructor( telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, - client: HttpClient = HttpClient(), - callsFactories: List = emptyList(), - excludeDefaultFactories: Boolean = false, - private val requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter, - private val jsonFormatter: Json = nonstrictJsonFormat, - private val pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder + client: HttpClient, + callsFactories: List, + excludeDefaultFactories: Boolean, + private val requestsLimiter: RequestLimiter, + private val jsonFormatter: Json, + private val pipelineStepsHolder: KtorPipelineStepsHolder, + diff: Unit ) : BaseRequestsExecutor(telegramAPIUrlsKeeper) { private val callsFactories: List = callsFactories.run { if (!excludeDefaultFactories) { diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor.kt index c8c6a73337..adb30b2228 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor.kt @@ -4,9 +4,12 @@ import dev.inmo.micro_utils.coroutines.runCatchingSafely import dev.inmo.tgbotapi.bot.BaseRequestsExecutor import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory 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.requests.abstracts.Request import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper +import dev.inmo.tgbotapi.utils.nonstrictJsonFormat import io.ktor.client.* import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.first @@ -55,7 +58,8 @@ class MultipleClientKtorRequestsExecutor ( excludeDefaultFactories, requestsLimiter, jsonFormatter, - pipelineStepsHolder + pipelineStepsHolder, + Unit ) }.toSet() private val freeClients = MutableStateFlow>(requestExecutors) @@ -68,14 +72,15 @@ class MultipleClientKtorRequestsExecutor ( } } - constructor( + internal constructor( telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, client: HttpClient, callsFactories: List, excludeDefaultFactories: Boolean, requestsLimiter: RequestLimiter, jsonFormatter: Json, - pipelineStepsHolder: KtorPipelineStepsHolder + pipelineStepsHolder: KtorPipelineStepsHolder, + diff: Unit ) : this( telegramAPIUrlsKeeper, callsFactories, diff --git a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt b/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.actual.jvm.kt similarity index 100% rename from tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.kt rename to tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutor.actual.jvm.kt