Skip to content

Commit

Permalink
Schedule purge task
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek committed Jun 7, 2024
1 parent 7cfe5c8 commit 8bbb4c1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/app/actors/PeriodicActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import play.api.{Environment, Mode}

import javax.inject.Inject
import scala.concurrent.ExecutionContext
import scala.concurrent.duration.{FiniteDuration, HOURS}
import scala.concurrent.duration.{FiniteDuration, HOURS, SECONDS}

class PeriodicActor @Inject() (
tasksDao: InternalTasksDao,
Expand All @@ -31,13 +31,21 @@ class PeriodicActor @Inject() (
context.system.scheduler.scheduleWithFixedDelay(finalInitial, interval, self, UpsertTask(taskType))
}

private[this] def scheduleOnce(taskType: TaskType): Unit = {
context.system.scheduler.scheduleOnce(FiniteDuration(10, SECONDS)) {
UpsertTask(taskType)
}
}


private[this] val cancellables: Seq[Cancellable] = {
import TaskType._
scheduleOnce(ScheduleMigrateVersions)
Seq(
schedule(CleanupDeletions, FiniteDuration(1, HOURS)),
schedule(ScheduleMigrateVersions, FiniteDuration(12, HOURS)),
schedule(ScheduleSyncGeneratorServices, FiniteDuration(1, HOURS)),
schedule(CheckInvariants, FiniteDuration(1, HOURS)),
schedule(PurgeOldDeleted, FiniteDuration(1, HOURS))(FiniteDuration(5, SECONDS)),
)
}

Expand Down

0 comments on commit 8bbb4c1

Please sign in to comment.