Skip to content
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

Refactor command-running to run oneshots after startup #23

Merged
merged 2 commits into from
Aug 24, 2022
Merged

Conversation

djmitche
Copy link
Contributor

This refactors the command-running utilities to take the fx.Options as
variadic arguments, so that fxapps.OneShot can add its own fx.Option.

It uses a bit of reflection to convince Fx to gather the arguments to a
function without actually calling that function immediately, allowing
the oneShot function to run after app.Start has finished, when we're
sure that all components have started. This works around the startup
ordering bug in uber-go/fx#918.

This refactors the command-running utilities to take the fx.Options as
variadic arguments, so that fxapps.OneShot can add its own fx.Option.

It uses a bit of reflection to convince Fx to gather the arguments to a
function without actually calling that function immediately, allowing
the oneShot function to run after `app.Start` has finished, when we're
sure that all components have started.  This works around the startup
ordering bug in uber-go/fx#918.
@djmitche djmitche linked an issue Aug 12, 2022 that may be closed by this pull request
@djmitche
Copy link
Contributor Author

(somewhat arbitrarily picking you, @juliogreff, for review, just to entice you to look at the repo!)

This relies on the fix in fx versions >1.18.1 that ensures Invoke's are
run in order.
@djmitche djmitche merged commit 0f9d5c3 into main Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OneShot should use a Hook, rather than run things before startup
1 participant