Package dev.inmo.krontab

Types

KronScheduler
Link copied to clipboard
common
interface KronScheduler
This interface was created for abstraction of next operation.
KronSchedulerTz
Link copied to clipboard
common
interface KronSchedulerTz : KronScheduler
This interface extending KronScheduler to use DateTimeTz with taking into account offset of incoming time for next operation.
KronSchedulerWork
Link copied to clipboard
abstract class KronSchedulerWork(context: Context, workerParams: WorkerParameters) : CoroutineWorker
Use this class as a super class in case you wish to implement krontab-based enqueuing of works
KrontabTemplate
Link copied to clipboard
common
typealias KrontabTemplate = String
KrontabTemplateSchedulerWork
Link copied to clipboard
abstract class KrontabTemplateSchedulerWork(context: Context, workerParams: WorkerParameters) : KronSchedulerWork
Extend this class in case you wish to base on KrontabTemplate.
KrontabTemplateWrapper
Link copied to clipboard
common
data class KrontabTemplateWrapper(template: KrontabTemplate) : KronScheduler
This class contains template and can be simply serialized/deserialized.

Functions

buildSchedule
Link copied to clipboard
common
fun buildSchedule(incoming: KrontabTemplate): KronScheduler
fun buildSchedule(incoming: KrontabTemplate, defaultOffset: Minutes): KronSchedulerTz
createSimpleScheduler
Link copied to clipboard
common
fun createSimpleScheduler(incoming: KrontabTemplate): KronScheduler
Parse incoming string and adapt according to next format: "* * * * *" where order of things:
  • seconds

  • minutes

  • hours

  • dayOfMonth

  • month

  • (optional) year

  • (optional) (can be placed anywhere after month) (must be marked with o at the end, for example: 60o == +01:00) offset

  • (optional) (can be placed anywhere after month) dayOfWeek

And each one (except of offsets) have next format:{number}[,{number},...] or *and {number} here is one of
  • {int}-{int}

  • {int}/{int}

  • */{int}

  • {int}

  • F

  • L

Week days must be marked with w at the end, and starts with 0 which means Sunday.
fun createSimpleScheduler(incoming: KrontabTemplate, defaultOffset: Minutes): KronSchedulerTz
doInfinity
Link copied to clipboard
common
inline suspend fun KronScheduler.doInfinity(noinline block: suspend () -> Unit)
Will execute block without any checking of result
inline suspend fun doInfinity(scheduleConfig: String, noinline block: suspend () -> Unit)
Will buildSchedule using scheduleConfig and call doInfinity with block
doOnce
Link copied to clipboard
common
inline suspend fun <T> KronScheduler.doOnce(noinline block: suspend () -> T): T
Execute block once at the KronScheduler.next time and return result of block calculation.
inline suspend fun <T> doOnce(scheduleConfig: String, noinline block: suspend () -> T): T
Will buildSchedule using scheduleConfig and call doOnce on it
doWhile
Link copied to clipboard
common
inline suspend fun KronScheduler.doWhile(noinline block: suspend () -> Boolean)
Will execute block while it will return true as a result of its calculation
inline suspend fun doWhile(scheduleConfig: String, noinline block: suspend () -> Boolean)
Will buildSchedule using scheduleConfig and call doWhile with block
enqueueKronSchedulerWork
Link copied to clipboard
inline suspend fun <T : KronSchedulerWork> Context.enqueueKronSchedulerWork(workName: String, initialScheduler: KronScheduler, existingWorkPolicy: ExistingWorkPolicy = ExistingWorkPolicy.REPLACE, noinline setUpRequest: suspend OneTimeWorkRequest.Builder.() -> Unit = {}): Operation?
This method is shortcut for enqueueKronSchedulerWork with reified T
inline suspend fun <T : KronSchedulerWork> Context.enqueueKronSchedulerWork(workName: String, delayMillis: Long, existingWorkPolicy: ExistingWorkPolicy = ExistingWorkPolicy.REPLACE, noinline setUpRequest: suspend OneTimeWorkRequest.Builder.() -> Unit = {}): Operation
This method is shortcut for enqueueKronSchedulerWork with reified T parameter
suspend fun <T : KronSchedulerWork> Context.enqueueKronSchedulerWork(workName: String, initialScheduler: KronScheduler, workClass: Class<T>, existingWorkPolicy: ExistingWorkPolicy = ExistingWorkPolicy.REPLACE, setUpRequest: suspend OneTimeWorkRequest.Builder.() -> Unit = {}): Operation?
This method is shortcut for enqueueKronSchedulerWork with initialScheduler.
suspend fun <T : KronSchedulerWork> Context.enqueueKronSchedulerWork(workName: String, delayMillis: Long, workClass: Class<T>, existingWorkPolicy: ExistingWorkPolicy = ExistingWorkPolicy.REPLACE, setUpRequest: suspend OneTimeWorkRequest.Builder.() -> Unit = {}): Operation
This method will enqueue OneTimeWorkRequest with workName and existingWorkPolicy.
enqueueKrontabTemplateSchedulerWork
Link copied to clipboard
inline suspend fun <T : KrontabTemplateSchedulerWork> Context.enqueueKrontabTemplateSchedulerWork(workName: String, krontabTemplate: KrontabTemplate, existingWorkPolicy: ExistingWorkPolicy = ExistingWorkPolicy.REPLACE, noinline setUpRequest: suspend OneTimeWorkRequest.Builder.(data: Data) -> Unit = {}): Operation?
merge
Link copied to clipboard
common
inline fun Iterable<KronScheduler>.merge(): CollectionKronScheduler
Create new one CollectionKronScheduler to include all KronSchedulers of this
fun Iterator<KronScheduler>.merge(): CollectionKronScheduler
Create new one CollectionKronScheduler to include all KronSchedulers of this
inline fun merge(vararg kronDateTimeSchedulers: KronScheduler): CollectionKronScheduler
next
Link copied to clipboard
common
suspend fun KronScheduler.next(relatively: DateTimeTz): DateTimeTz?
nextOrNow
Link copied to clipboard
common
suspend fun KronScheduler.nextOrNow(): DateTime
nextOrNowWithOffset
Link copied to clipboard
common
suspend fun KronSchedulerTz.nextOrNowWithOffset(): DateTimeTz
nextOrRelative
Link copied to clipboard
common
suspend fun KronScheduler.nextOrRelative(relatively: DateTime = DateTime.now()): DateTime
suspend fun KronSchedulerTz.nextOrRelative(relatively: DateTimeTz): DateTimeTz
nextTimeZoned
Link copied to clipboard
common
suspend fun KronScheduler.nextTimeZoned(): DateTimeTz?
toKronScheduler
Link copied to clipboard
common
fun KrontabTemplate.toKronScheduler(): KronScheduler
Shortcut for buildSchedule
fun KrontabTemplate.toKronScheduler(defaultOffset: Minutes): KronSchedulerTz
Shortcut for buildSchedule
toSchedule
Link copied to clipboard
common
fun KrontabTemplate.toSchedule(): KronScheduler
Shortcut for buildSchedule
fun KrontabTemplate.toSchedule(defaultOffset: Minutes): KronSchedulerTz
Shortcut for buildSchedule
wrapAsKronScheduler
Link copied to clipboard
common
Will create KrontabTemplateWrapper from this

Properties

AnyTimeScheduler
Link copied to clipboard
common
val AnyTimeScheduler: KronScheduler
KronScheduler.next will always return com.soywiz.klock.DateTime.now
EveryDayOfMonthScheduler
Link copied to clipboard
common
val EveryDayOfMonthScheduler: KronScheduler
KronScheduler.next will always return com.soywiz.klock.DateTime.now + one day
EveryHourScheduler
Link copied to clipboard
common
val EveryHourScheduler: KronScheduler
KronScheduler.next will always return com.soywiz.klock.DateTime.now + one hour
EveryMinuteScheduler
Link copied to clipboard
common
val EveryMinuteScheduler: KronScheduler
KronScheduler.next will always return com.soywiz.klock.DateTime.now + one minute
EveryMonthScheduler
Link copied to clipboard
common
val EveryMonthScheduler: KronScheduler
KronScheduler.next will always return com.soywiz.klock.DateTime.now + one month
EverySecondScheduler
Link copied to clipboard
common
val EverySecondScheduler: KronScheduler
KronScheduler.next will always return com.soywiz.klock.DateTime.now + one second
EveryYearScheduler
Link copied to clipboard
common
val EveryYearScheduler: KronScheduler
KronScheduler.next will always return com.soywiz.klock.DateTime.now + one year
krontabTemplateWorkField
Link copied to clipboard
const val krontabTemplateWorkField: String