fx icon indicating copy to clipboard operation
fx copied to clipboard

Refresh dependency

Open Juandavi1 opened this issue 2 years ago β€’ 5 comments

Hi πŸ‘‹ awesome project !

We have a microservice with spring cloud config integration.

Do you know how we can refresh dependencies when the spring cloud config changes ?

Juandavi1 avatar Jul 20 '23 05:07 Juandavi1

Hey, could you provide an example of the issue, perhaps with some code?

r-hang avatar Jul 25 '23 18:07 r-hang

Hi πŸ‘‹ It is a question not an issueπŸ™‹πŸ»β€β™‚οΈ How we can recreate an instance at runtime with fx ?

Juandavi1 avatar Jul 25 '23 18:07 Juandavi1

Not sure how you have set up the fx app currently. But if you don't need the app's state to persist between refreshes I imagine you could just re-create an fx.App, right?

sywhang avatar Jul 25 '23 18:07 sywhang

is correct, but that would start the entire application completely including the server. the idea is to update only one dependency within the app.

Juandavi1 avatar Jul 25 '23 18:07 Juandavi1

This isn't something that's supported in Fx.

Thinking out loud though, to support such a feature, we can't update a single dependency within the app. At the very least, this will need to update anything that depends on that particular dependency, so it'll need to re-populate potentially a big chunk of the app.

Another interesting point to consider is what to do with the lifecycle hooks - i.e. when a dependency is "re-loaded", does it run the onstop hook of the previously registered dependency, what about its onstart hook, etc.

These are interesting points of discussion that warrants some more thought into the design.

sywhang avatar Jul 27 '23 21:07 sywhang