extend scheduler shortcuts

This commit is contained in:
InsanusMokrassar 2019-10-08 23:04:58 +06:00
parent d1f84ee136
commit 726e68c114
2 changed files with 28 additions and 6 deletions

View File

@ -3,12 +3,6 @@ package com.github.insanusmokrassar.krontab
import com.soywiz.klock.DateTime import com.soywiz.klock.DateTime
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
private val anyCronDateTime by lazy {
CronDateTime()
}
val AnyTimeScheduler = CronDateTimeScheduler(listOf(anyCronDateTime))
data class CronDateTimeScheduler internal constructor( data class CronDateTimeScheduler internal constructor(
internal val cronDateTimes: List<CronDateTime> internal val cronDateTimes: List<CronDateTime>
) )

View File

@ -0,0 +1,28 @@
package com.github.insanusmokrassar.krontab
import com.github.insanusmokrassar.krontab.builder.buildSchedule
internal val anyCronDateTime by lazy {
CronDateTime()
}
val AnyTimeScheduler by lazy {
CronDateTimeScheduler(listOf(anyCronDateTime))
}
val EverySecondScheduler
get() = AnyTimeScheduler
val EveryMinuteScheduler by lazy {
buildSchedule { minutes { 0 every 1 } }
}
val EveryHourScheduler by lazy {
buildSchedule { hours { 0 every 1 } }
}
val EveryDayOfMonthScheduler by lazy {
buildSchedule { dayOfMonth { 0 every 1 } }
}
val EveryMonthScheduler by lazy {
buildSchedule { months { 0 every 1 } }
}