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

Allow depinject interface type resolution to be configured per module #11911

Closed
Tracked by #11899
aaronc opened this issue May 9, 2022 · 3 comments
Closed
Tracked by #11899

Allow depinject interface type resolution to be configured per module #11911

aaronc opened this issue May 9, 2022 · 3 comments
Labels
C:depinject Issues and PR related to depinject

Comments

@aaronc
Copy link
Member

aaronc commented May 9, 2022

Problem Definition

In #11873 (comment), @ValarDragon points out there are cases where a different instance of the same keeper interface needs to be provided to different modules.

Proposed Solution

In #11910, we propose allowing matching depinject interface types to be resolved using a key to enable the "expected keepers" pattern. This could be extended with some sort of "prefers" directives both at the container level and in app config. These prefers directives could be configure container wide and at a module scope.

Ex:

modules:
  - name: foo
    config:
      "@type": cosmos.foo.module.v1.Module
    golang_prefer:
      cosmos.staking.v1.Keeper: github.com/cosmos/cosmos-sdk/x/specialstaking.Keeper
@aaronc
Copy link
Member Author

aaronc commented May 31, 2022

Note that an alternative way to address this with the current depinject framework is with module-scoped providers. So before we implement this we should first see if that is sufficient

@aaronc aaronc changed the title Allow container interface type resolution to be configured per module Allow depinject interface type resolution to be configured per module May 31, 2022
@kocubinski
Copy link
Member

Resolution of #11910 seems to also resolve this issue.

@kocubinski
Copy link
Member

Fixed in #12169

Repository owner moved this from 📝 Todo to 👏 Done in Cosmos-SDK Jul 18, 2022
@tac0turtle tac0turtle removed this from Cosmos-SDK Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:depinject Issues and PR related to depinject
Projects
None yet
Development

No branches or pull requests

3 participants