com.lightningkite.lightningserver.schedule.Scheduler.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of server-core Show documentation
Show all versions of server-core Show documentation
A set of tools to fill in/replace what Ktor is lacking in.
The newest version!
package com.lightningkite.lightningserver.schedule
import java.time.Duration
import java.time.LocalTime
import java.time.ZoneId
object Scheduler {
val schedules: MutableMap = HashMap()
}
data class ScheduledTask(val name: String, val schedule: Schedule, val handler: suspend () -> Unit) {
override fun toString(): String = "SCHEDULE $name"
}
sealed class Schedule {
data class Frequency(val gap: Duration) : Schedule()
data class Daily(val time: LocalTime, val zone: ZoneId = ZoneId.systemDefault()) : Schedule()
}