Coverage Summary for Class: SchedulerKt (dev.suresh.routes)

Class Method, % Branch, % Line, % Instruction, %
SchedulerKt 0% (0/2) 0% (0/4) 0% (0/29)
SchedulerKt$scheduledTasks$1 0% (0/1) 0% (0/1) 0% (0/26)
SchedulerKt$scheduledTasks$1$1 0% (0/1) 0% (0/1) 0% (0/11)
Total 0% (0/4) 0% (0/6) 0% (0/66)


 package dev.suresh.routes
 
 import dev.suresh.virtualThreadScope
 import io.github.kevincianfarini.cardiologist.*
 import io.ktor.server.application.*
 import io.ktor.util.logging.*
 import io.opentelemetry.instrumentation.annotations.*
 import kotlin.time.Duration.Companion.seconds
 import kotlinx.coroutines.*
 import kotlinx.datetime.*
 
 fun Application.scheduledTasks() {
   log.info("Starting scheduled tasks...")
   virtualThreadScope.launch {
     Clock.System.fixedPeriodPulse(10.seconds).beat(PulseBackpressureStrategy.SkipNext) { scheduled
       ->
       context(log) { task("Task at ${scheduled.toLocalDateTime(TimeZone.currentSystemDefault())}") }
     }
   }
 }
 
 @WithSpan("scheduled-task")
 context(log: Logger)
 fun task(name: String) {
   try {
     log.warn("Running $name")
     // log.info("Scheduled task: ${MediaApiClient().images().size}")
   } catch (e: Exception) {
     log.error("Failed to run scheduled task: ${e.message}", e)
   }
 }