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

Add support to invoke a function between multiple containers #289

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

RobyFerro
Copy link

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.

@CLAassistant
Copy link

CLAassistant commented Aug 19, 2021

CLA assistant check
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.

✅ RobyFerro
❌ 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.

@RobyFerro
Copy link
Author

This method can be also used to invoke reflected interface:

if err := dig.GroupInvoke(method.Interface(), container, singletonIOC); err != nil {
    // Handle error
}

@abhinav
Copy link
Collaborator

abhinav commented Nov 4, 2021

Oops, I missed that this was a re-open of #288.
Copying part of #288 (comment) 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.]

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

Successfully merging this pull request may close these issues.

None yet

3 participants