"suspend" an issue when working with ktor + Exposed


#1

I am attempting to use ktor and exposed together.

With ktor, the entire handler for a route is a suspendable function suspend PipelineContext<TSubject, TContext>.(TSubject) -> Unit to be more precise. Within that I am performing multiple database calls using kotlin which obviously require these to be wrapped by a Kotlin transaction{ ... } which is not marked as a suspend.

I could perhaps wrap the transactions inside async {} but not sure if that is the appropriate way

On a broader note, what would be an idiomatic way of writing a ktor handler which pretty much is an activity which continuously occupying the CPU except when reading from the database or writing back a response.

Thanks.