https://kotlinlang.org logo
#ktor
Title
# ktor
s

simon.vergauwen

10/02/2023, 10:29 AM
What is the proper way to implement a custom Ktor plugin that runs
suspend
in the
Application
? 🤔 It's an integration, so my signature looks something like this
fun Application.integration(block: suspend IntegrationPlugin.() -> Unit): ?
.
?
can be
Job
, or
IntegrationPlugin
. Is the proper way to just use
launch { }
on the
Application
? The code running inside should get cancelled on
ApplicationStopping
anyway.
c

Chris Athanas

10/02/2023, 7:30 PM
Arent all kotlin functions suspend by default? I don’t think you need to do anything special here, if I am understanding your use-case.
s

simon.vergauwen

10/02/2023, 7:32 PM
No, not all Kotlin functions are
suspend
only those explicitly marked by
suspend
. The module function of Ktor is non-suspending, only the route functions are suspending.
4 Views