I am trying to understand why in a typical CRUD se...
# ktor
f
I am trying to understand why in a typical CRUD server I should mark the service and repository functions with suspend. As far as I understood, Ktor requests run in a Dispatcher.IO (?). If all my requests are Route - Service - Repository calls, what are the benefits in marking the service and repository functions with suspend? or using
withContext(<http://Dispatcher.IO|Dispatcher.IO>)
in the repository or service layer before performing IO operations? I know this would be beneficial if I had to execute for example multiple async tasks within the same request call, but this is not the case.
a
Related: https://kotlinlang.slack.com/archives/C0A974TJ9/p1710005378464099 As far as I know, if everything is running already on IO dispatcher which is meant to execute blocking operations, there is no benefit of doing what you said because it’s already there. But… I’m only trying to understand too so…