I asked in the Kafka Slack server how to handle testing a polling mechanism I have for consuming messages, that runs indefinitely. The solution offered was a CountdownLatch, which would allow me to halt the polling while testing.
I’m wondering if there is a more “Kotlin-esk” way to solve this rather than the countdown latch?
a
Adam S
05/21/2023, 7:10 PM
could you share an example of the code you have at the moment?
there’s some docs on async programming techniques here: https://kotlinlang.org/docs/async-programming.html#coroutines
Coroutines are good for suspending work, and they’re very Kotlin-esque, but they are a big step to take if you just want a small util in your test code!
I ripped that out, which locally seemed to fix it but once I pushed it into my cluster as container I was back to seeing my consumer being closed out from underneath me.
BryanT
05/21/2023, 7:49 PM
It’s just a toy project to try and learn Kotlin and have something to deploy into my little Microk8s cluster, so I would like to learn coroutines. I’m just not sure if how I’m using it here is on the right track.