mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 15:19:30 +00:00
add RequestsExecutor.Log
This commit is contained in:
@@ -246,6 +246,7 @@ public abstract class dev/inmo/tgbotapi/bot/BaseRequestsExecutor : dev/inmo/tgbo
|
||||
|
||||
public abstract interface class dev/inmo/tgbotapi/bot/RequestsExecutor : java/io/Closeable {
|
||||
public abstract fun execute (Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun getLog ()Ldev/inmo/kslog/common/KSLog;
|
||||
}
|
||||
|
||||
public abstract class dev/inmo/tgbotapi/bot/exceptions/BotException : java/io/IOException, kotlinx/coroutines/CopyableThrowable {
|
||||
@@ -416,6 +417,7 @@ public final class dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactoryKt
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor : dev/inmo/tgbotapi/bot/BaseRequestsExecutor {
|
||||
public fun close ()V
|
||||
public fun execute (Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun getLog ()Ldev/inmo/kslog/common/KSLog;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/base/DownloadFileChannelRequestCallFactory : dev/inmo/tgbotapi/bot/ktor/KtorCallFactory {
|
||||
@@ -439,6 +441,7 @@ public final class dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExe
|
||||
public fun <init> (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Ljava/util/List;ZLdev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;Lkotlinx/serialization/json/Json;Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;ILdev/inmo/kslog/common/KSLog;Lkotlin/jvm/functions/Function0;)V
|
||||
public fun close ()V
|
||||
public fun execute (Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun getLog ()Ldev/inmo/kslog/common/KSLog;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/base/SimpleRequestCallFactory : dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory {
|
||||
@@ -541,6 +544,7 @@ public final class dev/inmo/tgbotapi/bot/multiserver/SimpleMultiServerRequestsEx
|
||||
public synthetic fun <init> (Ljava/util/List;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function0;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun close ()V
|
||||
public fun execute (Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun getLog ()Ldev/inmo/kslog/common/KSLog;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/multiserver/SimpleMultiServerRequestsExecutor$Companion {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.bot
|
||||
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
|
||||
@@ -11,6 +12,8 @@ import io.ktor.utils.io.core.Closeable
|
||||
* @see dev.inmo.tgbotapi.bot.Ktor.KtorRequestsExecutor
|
||||
*/
|
||||
interface RequestsExecutor : Closeable {
|
||||
val Log: KSLog?
|
||||
get() = null
|
||||
/**
|
||||
* Unsafe execution of incoming [request]. Can throw almost any exception. So, it is better to use
|
||||
* something like [dev.inmo.tgbotapi.extensions.utils.shortcuts.executeAsync] or
|
||||
|
@@ -29,6 +29,7 @@ expect class KtorRequestsExecutor internal constructor(
|
||||
logger: KSLog,
|
||||
diff: Unit // just a diff property to know where constructor and where calling function with defaults
|
||||
) : BaseRequestsExecutor {
|
||||
override val Log: KSLog?
|
||||
override suspend fun <T : Any> execute(request: Request<T>): T
|
||||
override fun close()
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ class DefaultKtorRequestsExecutor internal constructor(
|
||||
private val logger: KSLog,
|
||||
diff: Unit
|
||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||
override val Log: KSLog? = logger
|
||||
private val callsFactories: List<KtorCallFactory> = callsFactories.run {
|
||||
if (!excludeDefaultFactories) {
|
||||
this@DefaultKtorRequestsExecutor.logger.v { "Installing default factories" }
|
||||
|
@@ -46,7 +46,7 @@ class MultipleClientKtorRequestsExecutor(
|
||||
jsonFormatter: Json,
|
||||
pipelineStepsHolder: TelegramBotPipelinesHandler,
|
||||
requestExecutorsCount: Int,
|
||||
logger: KSLog,
|
||||
override val Log: KSLog,
|
||||
clientFactory: () -> HttpClient,
|
||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||
private val requestExecutors = (0 until requestExecutorsCount).map {
|
||||
@@ -58,7 +58,7 @@ class MultipleClientKtorRequestsExecutor(
|
||||
requestsLimiter,
|
||||
jsonFormatter,
|
||||
pipelineStepsHolder,
|
||||
logger,
|
||||
Log,
|
||||
Unit
|
||||
)
|
||||
}.toSet()
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.bot.multiserver
|
||||
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutorBuilder
|
||||
import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
||||
import dev.inmo.tgbotapi.bot.RequestsExecutor
|
||||
@@ -29,6 +30,8 @@ class SimpleMultiServerRequestsExecutor(
|
||||
bots.forEach(TelegramBot::close)
|
||||
}
|
||||
) : RequestsExecutor {
|
||||
override val Log: KSLog?
|
||||
get() = bots.firstNotNullOfOrNull { it.Log }
|
||||
override suspend fun <T : Any> execute(request: Request<T>): T {
|
||||
var currentBot = bots.botSelector(-1, null)
|
||||
while (currentCoroutineContext().isActive) {
|
||||
|
Reference in New Issue
Block a user