Skip to content

Commit

Permalink
Fix to store less schedule and clean it up more often
Browse files Browse the repository at this point in the history
  • Loading branch information
IB committed Nov 13, 2023
1 parent 071c3bc commit e93f46c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/SchedulePolicy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ class Cron(
}


val onceAtMidnight = Cron("0 0 * * *")
val everyHour = Cron("0 * * * *")
2 changes: 1 addition & 1 deletion src/main/kotlin/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/TaskManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down

0 comments on commit e93f46c

Please sign in to comment.