-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for hooking after provide stage / Modification of Options on boot #698
Comments
This could be similar to the CompilerPasses from Symfony |
Repeating part of uber-go/dig#263 (comment) here for when we come back to this feature. Unfortunately, we do not yet have plans to support a feature like this in Fx. We've wrestled with this idea before, discussing it even during the initial release of Fx. After having a few years of experience running Fx in production,
These issues will be greatly amplified if we add support for arbitrary function execution before the graph is even fully visible. We're open to reconsidering this in the future, but it's not the highest priority feature on our list right now. We have work in flight to significantly alter a number of Fx's internals, so we'd like to focus on that before we consider another complex feature. However, when we do discuss this feature, we'd probably want the design to account for the following: We'll want to fully understand how lifecycle hooks will interact with the feature. Currently at startup, Fx effectively has these two phases: invoke everything, run all startup hooks. With Late Provides, the invoke everything stage will now do a lot more. We have no means of guarding against RPC calls being made there so we'd want to make a good choice of how those should interact with lifecycle hooks. Should lifecycle hooks be implemented in terms of Late Provides? Further, we'd want a deliberate focus on error messaging for such an API so that it is obvious to users at startup why their application failed. |
@abhinav Thanks for the response. Perfectly valid. fx beauty is definitely in its simplicity. I do think that this could be supported in a much more limited fashion though and solve my usecase issue. First pass wouldn't allow for injecting the fx.Lifecycle and would only allow for a constructor. Basically, a way to populate groups dynamically, which is something that is already supported. RPC's in a constructor are a no-no as it is. |
With this one could add more fx.Options before running the invokes. As example I wrote a small wrapper to inject all configs as struct into the graph. With this Feature one could hook into fx and check if a module is enabled by using these structs and if it is enabled provide more Invokes/Provide options.
The text was updated successfully, but these errors were encountered: