Job

interface Job

Kronos Job For Scheduling tasks

Properties

Link copied to clipboard
abstract val name: String

The Job Name. this should be unique

Link copied to clipboard
open val retries: Int

The number of times the job should be retired, overridden by 'retries' in Kronos.schedulePeriodic

Functions

Link copied to clipboard
open fun challengeRun(cycleNumber: Int, params: Map<String, Any>): Boolean

Custom pre-run gate called after Kronos's own scheduling validation. Return true to skip this cycle; return false (default) to allow execution.

Link copied to clipboard
open suspend fun execute(cycleNumber: Int, params: Map<String, Any>): Boolean

execute task for job, return true if job was successful

Link copied to clipboard
open fun onDrop(jobId: String, lastJob: Boolean)

Called each time a job record is removed from the database. lastJob is true when no further jobs with this name remain.

Link copied to clipboard
open fun onFail(cycleNumber: Int, params: Map<String, Any>, exception: Exception?)

Called once after all retries are exhausted and the job has still not succeeded.

Link copied to clipboard
open fun onLasCycleDrop(jobId: String, params: Map<String, Any>)

Called when the final cycle of a bounded job (maxCycles or endTime) completes and the job is dropped.

Link copied to clipboard
open fun onRetryFail(retryCount: Int, cycleNumber: Int, params: Map<String, Any>, exception: Exception?)

Called after each individual retry attempt fails. retryCount goes from 1 to retries. onFail is called once all retries are exhausted.

Link copied to clipboard
open fun onSuccess(cycleNumber: Int, params: Map<String, Any>)

Called when execute returns true.

Link copied to clipboard
open fun periodicJobLoaded(originJobId: String, nextJobId: String)

Called when the next occurrence of a repeating job has been inserted into the database. Useful for tracking the current job ID when you hold a reference to it.