Skip to content

Commit

Permalink
Update all non-major dependencies (#15)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
renovate[bot] and GeneralTao2 authored Sep 9, 2024
1 parent bd72284 commit 508e982
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version>
<version>3.3.3</version>
<relativePath/>
</parent>

Expand Down
9 changes: 7 additions & 2 deletions src/main/kotlin/org/taonity/vkforwarderbot/YtYlpService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion src/templates/docker/flyway/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "{{ "
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/automation/steps/TgStepDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TgStepDefinition {
val rows = table.asMaps(String::class.java, String::class.java)
val retryPolicy = RetryPolicy.builder<Void>()
.handle(AssertionFailedError::class.java)
.withMaxRetries(60)
.withMaxRetries(100)
.withDelay(Duration.ofSeconds(1))
.build()

Expand Down

0 comments on commit 508e982

Please sign in to comment.