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

Introduce a framework for components lifecycle #627

Open
yurishkuro opened this issue Jan 1, 2018 · 1 comment
Open

Introduce a framework for components lifecycle #627

yurishkuro opened this issue Jan 1, 2018 · 1 comment
Assignees

Comments

@yurishkuro
Copy link
Member

The main functions of query/collector/standalone have a lot of duplication due to the way various components are configured, initialized, used. We could do better.

At minimum, all components that provide CLI flags and initialization from Viper could be written as plugin.Configurable instances (from #625) which will reduce the boilerplate code by 30%. Right now every component is called 3 times: to AddFlags, to instantiate the actual Options struct, and to InitFromViper. A simple change is to instantiate them all as objects first, then add them all to a list so that AddFlags and InitFromViper can be done on the collection.

A possible extension is to look into some dependency injection frameworks like https://github.com/uber-go/fx.

@yurishkuro yurishkuro self-assigned this Jan 1, 2018
@jpkrohling
Copy link
Contributor

I think you did something in this direction as part of #1442, but would still be nice to go one step further and adopt a dependency injection framework. This would also probably help with #355.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants