-
-
Notifications
You must be signed in to change notification settings - Fork 81
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 of Value Groups #52
Comments
That last sentence captures the main difference between ProvideValue and something like ProvideGroupItem. The major difference is that populating the di container should not be centralized. I could create multiple IRoute in multiple contructors. If I need to append them all in a slice in a central place before injection, I need something to be aware of all the route constructors. Adding something like I'm gonna try to think about a possible API to achieve this. |
Here are some ideas about api 👇 Dedicated helpers:
Reuse existing helpers:
Note:
Injectors: About implem, we have 2 options:
I would be in favor of one of the last 2 options. FYI, to date, we are not able to inject a service twice in a scope. |
Other implemention possibility: having a service of type "group" containing the providers, that invoke parent scopes recursively and load all items whatever the scope of injection. |
Some thoughts:
I'm gonna continue my reflection during the holidays... |
I am currently looking into this project and started directly with using v2. IMO the Value Groups would be very useful and wanted to share my two use cases:
# example controller
func (c *FooController) Register(router chi.Router) {
router.Get("/bar", c.foobarHandler)
} It would be nice if I would be able to get every provided value which implements a certain interface. Ideally even lazily loaded ones. This would allow a very slim configuration of injected services, which is basically a list of all needed This feature btw looks like a generalization of the Shutdown and Healthcheck features. It would be possible to implement them easily by getting all provided values that implement the Shutdowner interface resp. Healthchecker interface. |
@matdurand :
The text was updated successfully, but these errors were encountered: