Can I in any way pass objects into a module while using an embedded server and reloading enabled ?
o
orangy
11/17/2017, 3:07 PM
What kind of object? Can you give an example?
s
spand
11/20/2017, 10:01 AM
Well, anything really. The usecase of now is just a config object.. but I think I need to pass in services soon.
o
orangy
11/20/2017, 10:39 AM
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
spand
11/20/2017, 10:51 AM
But there is no help from ktor in passing an instance to my application module function right? Or maybe I am missing something
spand
11/20/2017, 10:54 AM
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
orangy
11/20/2017, 10:54 AM
Is there a reason to create that value outside of the module?
s
spand
11/20/2017, 10:57 AM
Well, thats where we do our main method arg parsing
spand
11/20/2017, 10:57 AM
But in the future I think we need/prefer to have services persist across ktor instance lifecycles
o
orangy
11/20/2017, 11:47 AM
I see, I need to think about it… It’s complicated with all the class loading magic
orangy
11/20/2017, 11:47 AM
Could you please describe it in the issue, so it doesn’t get lost and we can add some notes/discussion there?