when working with ktor, is there any documentation...
# ktor
g
when working with ktor, is there any documentation about the coroutineScope that is given you when you expose an endpoint? Are there any best practices when it comes to calling businessServices from the “controller/endpoints”-layer? E.g. what happens if you from an endpoint call a blocking service?
e
@Vsevolod Tolstopyatov [JB]
m
If you call a blocking service you probably want to use the IO dispatcher which is made available to you for that purpose, e.g.
withContext(IO) { slowCallHere() }
. Note that it's for blocking io calls, not cpu-intensive blocking calls -- the cap on the number of threads is set high, and if you used them all for heavy cpu work it would be inefficient because there would be so much context switching.