Skip to content

Commit 5bf3777

Browse files
committed
A bit more logging from Job
1 parent e124c13 commit 5bf3777

File tree

1 file changed

+13
-7
lines changed
  • src/main/java/org/radarbase/output/worker

1 file changed

+13
-7
lines changed

src/main/java/org/radarbase/output/worker/Job.kt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ import java.util.concurrent.Future
99
import java.util.concurrent.ScheduledExecutorService
1010
import java.util.concurrent.TimeUnit
1111

12-
class Job(val name: String, val isEnabled: Boolean, val intervalSeconds: Long, val work: () -> Unit) {
12+
class Job(
13+
val name: String,
14+
val isEnabled: Boolean,
15+
private val intervalSeconds: Long,
16+
val work: () -> Unit
17+
) {
1318
fun run() {
1419
val timeStart = Instant.now()
20+
logger.info("Job {} started", name)
1521
try {
1622
work()
1723
logger.info("Job {} completed in {}", name, timeStart.durationSince().format())
@@ -27,12 +33,12 @@ class Job(val name: String, val isEnabled: Boolean, val intervalSeconds: Long, v
2733
}
2834
}
2935

30-
fun schedule(executorService: ScheduledExecutorService): Future<*> {
31-
return executorService.scheduleAtFixedRate(::run,
32-
intervalSeconds / 4,
33-
intervalSeconds,
34-
TimeUnit.SECONDS)
35-
}
36+
fun schedule(
37+
executorService: ScheduledExecutorService
38+
): Future<*> = executorService.scheduleAtFixedRate(::run,
39+
intervalSeconds / 4,
40+
intervalSeconds,
41+
TimeUnit.SECONDS)
3642

3743
companion object {
3844
private val logger = LoggerFactory.getLogger(Job::class.java)

0 commit comments

Comments
 (0)