Hi, I couldn't find info on the high level overvie...
# ktor
d
Hi, I couldn't find info on the high level overview of how ktor works. I have case, where I need to install an http client feature, which caches, provides and refreshes authentication tokens, which will be used when making http calls. But I am not sure about lifetimes and coroutine scopes. What I understand is that feature is installed just once and not per request? Which means all the state in the feature is available during the lifetime of the application? And what happens if I have a coroutine that throws an error while handling request to the server? I presume each request to ktor is handled in some parent coroutine, so error will just cancel that coroutine right? (like when in jetty world, where each request creates a thread)
c
Every feature is installed only once
Every call is handled in a separate coroutine under supervisor scope
So a crash inside of a handler will cancel it and all children
But other call handling coroutines will remain alive
In fact it's an implementation detail however in general I'd say that the whole call scope will be cancelled at handler crash
d
cool, cheers, that's what I was guessing. Another question: how is cancellation exception handled? Say there is timeoutcancellation in the feature interceptor. It will cancel call scope right?
c
it depends on what a feature is doing however the simple answer is yet