What is the proper way to implement a custom Ktor ...
# ktor
s
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
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
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.
👍 1