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

Satyam Agarwal

06/04/2022, 9:29 AM
Another question that is bugging me. In
ktor-server-call-logging
https://github.com/ktorio/ktor/blob/main/ktor-server/ktor-server-plugins/ktor-server-call-logging/jvm/src/io/ktor/server/plugins/callloging/MDCProvider.kt#L12 Here mdc entries are registered in the plugin registry, but I couldn’t find out where they are extracted again back from the plugin registry to be used (they are however used from the pluginConfig, so I don’t see why these are being registered in pluginRegistry). Is this code redundant or is there any magic that I cant see 😅 ?
s

Satyam Agarwal

06/04/2022, 9:43 AM
Ah I see. but eventually, all entries are evaluated for each call and its attributes, i guess ? So If I register my attributes in pluginRegistry, will they be automatically be applied to each
call
instance, thus removing the need to set them up in CallSetup hook ?
Just trying to fish out the relevance of pluginRegistry, and possible usage of it 🙂
a

Aleksei Tirman [JB]

06/06/2022, 9:59 AM
Could you please describe what problem are you trying to solve with the pluginRegistry?
s

Satyam Agarwal

06/06/2022, 10:02 AM
Actually, I don't really have a use case. I wasn't aware about something like pluginRegistry. So I wanted to know more about it. Seems like a good way to register attributes that needs to be provided once and evaluated per call instance. So I wanted to know more about it, the thought process behind it.
a

Aleksei Tirman [JB]

06/06/2022, 10:05 AM
Generally, the plugin registry is used to store instances of installed plugins.
You can store attributes in the
Application.attributes
if you want to share data for all calls.
2 Views