uber-go/fx

Refresh dependency

Juandavi1 opened this issue Β· 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 ?

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

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

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?

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

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.