alon shoshani.86
12/23/2021, 8:57 AMsimon.vergauwen
12/23/2021, 8:58 AMsimon.vergauwen
12/23/2021, 8:59 AMfun Application.task(): Job = launch {
Schedule.spaced<Unit>(1.minutes).repeat {
// Run task
}
}simon.vergauwen
12/23/2021, 9:00 AMalon shoshani.86
12/23/2021, 9:35 AMalon shoshani.86
12/23/2021, 10:39 AMrunBlocking {
Schedule.spaced<Unit>(5.minutes).repeat {
<http://log.info|log.info> { "here" }
}
}alon shoshani.86
12/23/2021, 10:39 AMsimon.vergauwen
12/23/2021, 10:52 AMApplication from Ktor which is a CoroutineScope, and then you can launch the Job with the same lifecycle as your Ktor server.simon.vergauwen
12/23/2021, 10:52 AMfun Application.task(): Job = launch {
Schedule.spaced<Unit>(1.minutes).repeat {
// Run task
}
}
Application here is Ktor Application