From e93f46c697e0903991b4432bf6f4c490e991d1f3 Mon Sep 17 00:00:00 2001 From: IB Date: Mon, 13 Nov 2023 19:28:32 +0000 Subject: [PATCH] Fix to store less schedule and clean it up more often --- src/main/kotlin/SchedulePolicy.kt | 2 +- src/main/kotlin/Settings.kt | 2 +- src/main/kotlin/TaskManager.kt | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/SchedulePolicy.kt b/src/main/kotlin/SchedulePolicy.kt index e9ef5e7..41b7212 100644 --- a/src/main/kotlin/SchedulePolicy.kt +++ b/src/main/kotlin/SchedulePolicy.kt @@ -29,4 +29,4 @@ class Cron( } -val onceAtMidnight = Cron("0 0 * * *") \ No newline at end of file +val everyHour = Cron("0 * * * *") \ No newline at end of file diff --git a/src/main/kotlin/Settings.kt b/src/main/kotlin/Settings.kt index a4a0c12..721367e 100644 --- a/src/main/kotlin/Settings.kt +++ b/src/main/kotlin/Settings.kt @@ -9,7 +9,7 @@ object Settings { .seconds var scheduleTTL: Duration = System.getenv() - .getOrDefault("KOTASK_SCHEDULE_CLEANUP_SECONDS", "86400") // 1 day + .getOrDefault("KOTASK_SCHEDULE_CLEANUP_SECONDS", "3600") // 1 hour .toInt() .seconds diff --git a/src/main/kotlin/TaskManager.kt b/src/main/kotlin/TaskManager.kt index 30e6314..02ddf0f 100644 --- a/src/main/kotlin/TaskManager.kt +++ b/src/main/kotlin/TaskManager.kt @@ -8,7 +8,6 @@ import kotlinx.serialization.Serializable import org.slf4j.LoggerFactory import cleanScheduleWorker import kotlin.time.Duration -import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit @@ -72,7 +71,7 @@ class TaskManager( tasksSchedulers.getOrPut(cleanScheduleWorkloadName) { schedulersScope.launch { while (true) { - onceAtMidnight + everyHour .getNextCalls() .takeWhile { it < Clock.System.now() + Settings.schedulingHorizon } .forEach { date ->