Can I in any way pass objects into a module while ...
# ktor
s
Can I in any way pass objects into a module while using an embedded server and reloading enabled ?
o
What kind of object? Can you give an example?
s
Well, anything really. The usecase of now is just a config object.. but I think I need to pass in services soon.
o
The application is reloaded entirely, except for the engine and ktor core stuff, so if you use dependency injection, you can do it. However, no state is preserved in this case.
s
But there is no help from ktor in passing an instance to my application module function right? Or maybe I am missing something
Currently my best guess is to store the instance in a static field and fetching it from the application module function but not sure if itll work with the classloader stuff that is going on
o
Is there a reason to create that value outside of the module?
s
Well, thats where we do our main method arg parsing
But in the future I think we need/prefer to have services persist across ktor instance lifecycles
o
I see, I need to think about it… It’s complicated with all the class loading magic
Could you please describe it in the issue, so it doesn’t get lost and we can add some notes/discussion there?
s
Sure. It is done now