Hi all, I am very new to Kotlin and come from a Scala background, mainly from the Typelevel stack using cats-effect and the like. I’ve been told my new team use Kotlin heavily and I will be moving away from Scala for a rotation, so I am trying to get familiar with the language.
I have a quick question with regards to asynchronous programming, mainly concerning runBlocking
and coroutineScope
. I’m just wondering if there are general rules of thumb when using the two in production code, mainly to do with gRPC, microservices and the like, no UI code anywhere.
Am I correct in thinking a valid distinction would be to use coroutineScope
when performing database writes (that I do not need to receive a result for) so the thread can continue to perform other duties as those coroutines execute?
Would an example of using runBlocking
properly be when I need to perform some HTTP request, of which the result is crucial to the code immediately after the runBlocking
?
Does anyone know of any resources that might detail how this works in relation to Scala’s cats-effect?
Thanks!
submitted by /u/Sicarius154
[link] [comments]