r/Kotlin
Lessons from 10 months of building a Kotlin + Quarkus app compiled to a native image

Hi r/Kotlin (https://www.reddit.com/r/Kotlin),

For the past 10 months I've been building an open-source uptime monitoring tool in Kotlin on Quarkus, compiled to a native image, with PostgreSQL used as a job queue to coordinate several workers. Here are a few Kotlin-specific things I ran into, in case they save someone time, and I'd love to hear how you handle them.

1. Native image and serialization

Classes serialized with a snake_case naming strategy have to be explicitly registered for reflection in the native build. In JVM mode everything worked; in native mode the JSON field names silently differed from the API. Nothing failed at build time, so it only showed up at runtime.

2. LocalDateTime vs Instant

I started with LocalDateTime and ended up replacing it with Instant everywhere. With checks running on several workers and notifications formatted in the user's timezone, keeping everything in UTC and converting only at display time removed a whole class of bugs.

3. Concurrency around token refresh and shutdown

Concurrent token refreshes caused race conditions until I added locking. I also had to implement a graceful shutdown for executors with timeouts, so that in-flight checks finish cleanly when a worker stops.

4. Rotating an encryption key

Stored credentials (SMTP passwords, webhook secrets…) are encrypted. Supporting key rotation meant writing a re-encryption service that decrypts with the old key and re-encrypts with the new one without downtime.

Questions for you

• Do you rely on Quarkus/GraalVM reflection config, or do you avoid reflection entirely (e.g. kotlinx.serialization)?
• How do you structure coroutines vs Quarkus executors in a long-running scheduler?
• Any idiomatic Kotlin patterns you'd recommend for this kind of worker/queue design?
The code is here if you want to look at the details: https://github.com/TheoMeunier/uptime-kotlin

— u/isoxxxx
Lessons from 10 months of building a Kotlin + Quarkus app compiled to a native image

Hi r/Kotlin (https://www.reddit.coИсточник: reddit.com ↗

Комментарии

Комментариев пока нет.

Ответить можно в O2.