Package-level declarations

Types

Link copied to clipboard
interface KronScheduler

This interface was created for abstraction of next operation. Currently, there is only dev.inmo.krontab.internal.CronDateTimeScheduler realisation of this interface inside of this library, but you it is possible to create your own realisation of this interface for scheduling, for example, depending of users activity or something like this

Link copied to clipboard

This interface extending KronScheduler to use DateTimeTz with taking into account offset of incoming time for next operation.

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

Link copied to clipboard
Link copied to clipboard

Extend this class in case you wish to base on KrontabTemplate. It will automatically handle request of kronScheduler and put it in setUpRequest

Link copied to clipboard

This class contains template and can be simply serialized/deserialized. In fact that class will work as dev.inmo.krontab.internal.CronDateTimeScheduler due to the fact that toKronScheduler will return it under the hood

Link copied to clipboard
class LambdaKronScheduler(onNext: suspend (<Error class: unknown class>) -> <Error class: unknown class>?) : KronScheduler
Link copied to clipboard
class LambdaKronSchedulerTz(onNext: suspend (<Error class: unknown class>) -> <Error class: unknown class>?) : KronSchedulerTz

Functions

Link copied to clipboard
Link copied to clipboard

Parse incoming string and adapt according to next format: "* * * * *" where order of things:

Link copied to clipboard
inline suspend fun doInfinity(scheduleConfig: String, noinline block: suspend (<Error class: unknown class>) -> Unit)

Will buildSchedule using scheduleConfig and call doInfinity with block

Link copied to clipboard
inline suspend fun KronScheduler.doInfinity(noinline block: suspend (<Error class: unknown class>) -> Unit)

Will execute block without any checking of result

Link copied to clipboard
inline suspend fun doInfinityTz(scheduleConfig: String, noinline block: suspend (<Error class: unknown class>) -> Unit)

Will buildSchedule using scheduleConfig and call doInfinity with block

Link copied to clipboard
inline suspend fun KronScheduler.doInfinityTz(noinline block: suspend (<Error class: unknown class>) -> Unit)

Will execute block without any checking of result

Link copied to clipboard
inline suspend fun <T> doOnce(scheduleConfig: String, noinline block: suspend (<Error class: unknown class>) -> T): T

Will buildSchedule using scheduleConfig and call doOnce on it

Link copied to clipboard
inline suspend fun <T> KronScheduler.doOnce(noinline block: suspend (<Error class: unknown class>) -> T): T

Execute block once at the KronScheduler.next time and return result of block calculation.

Link copied to clipboard
inline suspend fun <T> doOnceTz(scheduleConfig: String, noinline block: suspend (<Error class: unknown class>) -> T): T

Will buildSchedule using scheduleConfig and call doOnce on it

Link copied to clipboard
inline suspend fun <T> KronScheduler.doOnceTz(noinline block: suspend (<Error class: unknown class>) -> T): T

Execute block once at the KronScheduler.next time and return result of block calculation.

Link copied to clipboard
inline suspend fun doWhile(scheduleConfig: String, noinline block: suspend (<Error class: unknown class>) -> Boolean)

Will buildSchedule using scheduleConfig and call doWhile with block

Link copied to clipboard
inline suspend fun KronScheduler.doWhile(noinline block: suspend (<Error class: unknown class>) -> Boolean)

Will execute block while it will return true as a result of its calculation

Link copied to clipboard
inline suspend fun doWhileTz(scheduleConfig: String, noinline block: suspend (<Error class: unknown class>) -> Boolean)

Will buildSchedule using scheduleConfig and call doWhile with block

Link copied to clipboard
inline suspend fun KronScheduler.doWhileTz(noinline block: suspend (<Error class: unknown class>) -> Boolean)

Will execute block while it will return true as a result of its calculation

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. It will try to calculate delay by itself. In case if KronScheduler.next of initialScheduler will return null, work WILL NOT be enqueued

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. Use setUpRequest callback in case you need some additional actions to do before request will be enqueued

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?

Will enqueueKronSchedulerWork with KronScheduler from krontabTemplate and call setUpRequest on setting up OneTimeWorkRequest.Builder with Data which will be used to OneTimeWorkRequest.Builder.setInputData after setUpRequest completed

Link copied to clipboard
fun KronScheduler(onNext: suspend (<Error class: unknown class>) -> <Error class: unknown class>?): LambdaKronScheduler
Link copied to clipboard
fun KronSchedulerTz(onNext: suspend (<Error class: unknown class>) -> <Error class: unknown class>?): LambdaKronSchedulerTz
Link copied to clipboard
inline fun merge(vararg kronDateTimeSchedulers: KronScheduler): CollectionKronScheduler
Link copied to clipboard
suspend fun KronScheduler.next(relatively: <Error class: unknown class>): <Error class: unknown class>
Link copied to clipboard
suspend fun KronScheduler.nextOrNow(): <Error class: unknown class>
Link copied to clipboard
suspend fun KronSchedulerTz.nextOrNowWithOffset(): <Error class: unknown class>
Link copied to clipboard
suspend fun KronScheduler.nextOrRelative(relatively: <Error class: unknown class> = DateTime.now()): <Error class: unknown class>
suspend fun KronSchedulerTz.nextOrRelative(relatively: <Error class: unknown class>): <Error class: unknown class>
Link copied to clipboard
suspend fun KronScheduler.nextTimeZoned(): <Error class: unknown class>?
Link copied to clipboard

Properties

Link copied to clipboard

KronScheduler.next will always return com.soywiz.klock.DateTime.now

Link copied to clipboard

KronScheduler.next will always return com.soywiz.klock.DateTime.now + one day

Link copied to clipboard

KronScheduler.next will always return com.soywiz.klock.DateTime.now + one hour

Link copied to clipboard

KronScheduler.next will always return com.soywiz.klock.DateTime.now + one millisecond

Link copied to clipboard

KronScheduler.next will always return com.soywiz.klock.DateTime.now + one minute

Link copied to clipboard

KronScheduler.next will always return com.soywiz.klock.DateTime.now + one month

Link copied to clipboard

KronScheduler.next will always return com.soywiz.klock.DateTime.now + one second

Link copied to clipboard

KronScheduler.next will always return com.soywiz.klock.DateTime.now + one year

Link copied to clipboard