Add support to invoke a function between multiple containers
This implementation allows developers to invoke specific function between multiple containers. This may be useful in case of you have a container instantiated at application startup (singleton container) and a second container instantiated just before handle every HTTP request (factory container).
With GroupInvoke you can resolve dependencies across singleton and factory container.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.
:white_check_mark: RobyFerro
:x: Roberto Ferro
Roberto Ferro seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.
This method can be also used to invoke reflected interface:
if err := dig.GroupInvoke(method.Interface(), container, singletonIOC); err != nil {
// Handle error
}
Oops, I missed that this was a re-open of #288. Copying part of https://github.com/uber-go/dig/pull/288#issuecomment-961485428 here.
Dig and Fx rely heavily on reflection to implement their functionality. For that reason, we advise that you use them only at startup, and do not use them on the request path.
Creating per-request containers to (presumably) build a request-scoped handler is not something we suggest doing with Dig. We instead recommend that you work around this limitation by manually implementing request-scoped handlers. [Original comment has an example of the recommended workaround.]