From 508e982726d6ecd9d8d1bdc07910ce72dce361ee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:47:35 +0300 Subject: [PATCH] Update all non-major dependencies (#15) * Update all non-major dependencies * allow an error log * increase AT timeout * fix a typo --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Artiom Diulgher --- pom.xml | 2 +- .../taonity/vkforwarderbot/YtYlpService.kt | 9 ++++++-- .../tg/TgMessageSendingRateLimiter.kt | 22 +++++++++---------- .../docker/flyway/docker-compose.yml | 2 +- .../automation/steps/TgStepDefinition.kt | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index c96d27d..028eafb 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ org.springframework.boot spring-boot-starter-parent - 3.3.2 + 3.3.3 diff --git a/src/main/kotlin/org/taonity/vkforwarderbot/YtYlpService.kt b/src/main/kotlin/org/taonity/vkforwarderbot/YtYlpService.kt index 1f04853..fca61cf 100644 --- a/src/main/kotlin/org/taonity/vkforwarderbot/YtYlpService.kt +++ b/src/main/kotlin/org/taonity/vkforwarderbot/YtYlpService.kt @@ -9,6 +9,7 @@ import java.util.stream.Collectors private val LOGGER = KotlinLogging.logger {} +private const val YT_YLP_ALLOWED_ERROR_LOG = "WARNING: [vk] Failed to download m3u8 information: HTTP Error 404: Not Found" @Component class YtYlpService( @@ -24,8 +25,12 @@ class YtYlpService( val ytDlpErrorLog = runDownloadingProcessAndWait(vkVideoUrl) if(ytDlpErrorLog.isNotEmpty()) { - LOGGER.error { ytDlpErrorLog } - return null + if (ytDlpErrorLog == YT_YLP_ALLOWED_ERROR_LOG) { + LOGGER.warn { ytDlpErrorLog } + } else { + LOGGER.error { ytDlpErrorLog } + return null + } } return cacheService.listFilesInCache().stream() diff --git a/src/main/kotlin/org/taonity/vkforwarderbot/tg/TgMessageSendingRateLimiter.kt b/src/main/kotlin/org/taonity/vkforwarderbot/tg/TgMessageSendingRateLimiter.kt index 1de0a3e..40586e2 100644 --- a/src/main/kotlin/org/taonity/vkforwarderbot/tg/TgMessageSendingRateLimiter.kt +++ b/src/main/kotlin/org/taonity/vkforwarderbot/tg/TgMessageSendingRateLimiter.kt @@ -50,15 +50,15 @@ class TgMessageSendingRateLimiter { } private fun calculateTotalSleepTime(timeNow: LocalDateTime, tokensLeft: Int): Long { - val millisToWaitForSecondsCircleEnd = getMillisFromNowUntilSecondsCircleEnd(timeNow) + val millisToWaitForSecondsCycleEnd = getMillisFromNowUntilSecondsCycleEnd(timeNow) val millisLeftUntilTokensRefill = getMillisFromNowUntilNexRefillTime(tokensLeft, timeNow) - return sumTotalSleepTime(millisToWaitForSecondsCircleEnd, millisLeftUntilTokensRefill) + return sumTotalSleepTime(millisToWaitForSecondsCycleEnd, millisLeftUntilTokensRefill) } - private fun sumTotalSleepTime(millisToWaitForSecondsCircleEnd: Long?, millisLeftUntilTokensRefill: Long?): Long { + private fun sumTotalSleepTime(millisToWaitForSecondsCycleEnd: Long?, millisLeftUntilTokensRefill: Long?): Long { var totalSleepTime = 0L - if (millisToWaitForSecondsCircleEnd != null) { - totalSleepTime += millisToWaitForSecondsCircleEnd + if (millisToWaitForSecondsCycleEnd != null) { + totalSleepTime += millisToWaitForSecondsCycleEnd } if (millisLeftUntilTokensRefill != null) { totalSleepTime += millisLeftUntilTokensRefill @@ -75,11 +75,11 @@ class TgMessageSendingRateLimiter { null } - private fun getMillisFromNowUntilSecondsCircleEnd(timeNow: LocalDateTime) = - if (getSecondCircleEndTime().isAfter(timeNow)) { - val millisToWaitForSecondsCircleEnd = ChronoUnit.MILLIS.between(timeNow, getSecondCircleEndTime()) - LOGGER.debug { "Seconds circle is active, have to sleep for ${millisToWaitForSecondsCircleEnd / 1000.0} secs" } - millisToWaitForSecondsCircleEnd + private fun getMillisFromNowUntilSecondsCycleEnd(timeNow: LocalDateTime) = + if (getSecondCycleEndTime().isAfter(timeNow)) { + val millisToWaitForSecondsCycleEnd = ChronoUnit.MILLIS.between(timeNow, getSecondCycleEndTime()) + LOGGER.debug { "Seconds cycle is active, have to sleep for ${millisToWaitForSecondsCycleEnd / 1000.0} secs" } + millisToWaitForSecondsCycleEnd } else { null } @@ -94,7 +94,7 @@ class TgMessageSendingRateLimiter { acquireTokensAndRun(1, runnable) } - private fun getSecondCircleEndTime(): LocalDateTime = lastAcquiringTime.plusSeconds(lastTokensUsed) + private fun getSecondCycleEndTime(): LocalDateTime = lastAcquiringTime.plusSeconds(lastTokensUsed) private fun getNextTokenRefillTime(): LocalDateTime = lastRefillTime.plusMinutes(1) } \ No newline at end of file diff --git a/src/templates/docker/flyway/docker-compose.yml b/src/templates/docker/flyway/docker-compose.yml index b7195ab..f132cf2 100644 --- a/src/templates/docker/flyway/docker-compose.yml +++ b/src/templates/docker/flyway/docker-compose.yml @@ -2,7 +2,7 @@ version: '2.4' services: flyway: - image: flyway/flyway:10.17.2 + image: flyway/flyway:10.17.3 command: migrate environment: FLYWAY_PLACEHOLDER_PREFIX: "{{ " diff --git a/src/test/kotlin/automation/steps/TgStepDefinition.kt b/src/test/kotlin/automation/steps/TgStepDefinition.kt index 69664a7..fe31efd 100644 --- a/src/test/kotlin/automation/steps/TgStepDefinition.kt +++ b/src/test/kotlin/automation/steps/TgStepDefinition.kt @@ -28,7 +28,7 @@ class TgStepDefinition { val rows = table.asMaps(String::class.java, String::class.java) val retryPolicy = RetryPolicy.builder() .handle(AssertionFailedError::class.java) - .withMaxRetries(60) + .withMaxRetries(100) .withDelay(Duration.ofSeconds(1)) .build()