-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat: add low-level dependency injection container API #9658
Conversation
Note that we will need to add github actions to cover all nested go modules (as in regen-network/regen-ledger#357). @cyberbono3 would you be able to support with that? |
// directly, but will instead use the struct's fields to resolve or populate | ||
// dependencies. Types with embedded StructArgs can be used in both the input | ||
// and output parameter positions. | ||
type StructArgs struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was simpler to have one struct vs dig.In
and dig.Out
... Wonder if anyone has an opinion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In / Out makes it more clear when reading a structure definition, without going into the provider / usage:
- when I see a struct with
dig.In
I quickly associate it with a dependencies of some type. - when I see a struct with
dig.Out
I see that those are some dependencies a provider can provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to change it to In/Out, but note that I also have structs named Input and Output here to describe the actual constructor inputs/outputs... Any suggestions on naming?
Codecov Report
@@ Coverage Diff @@
## master #9658 +/- ##
=======================================
Coverage 63.60% 63.60%
=======================================
Files 568 568
Lines 53509 53511 +2
=======================================
+ Hits 34034 34037 +3
+ Misses 17550 17549 -1
Partials 1925 1925
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval meant to move things forward as follow-up PRs have already been opened
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, maybe we can try to start some live code review of #9666 in the next WG call then?
// directly, but will instead use the struct's fields to resolve or populate | ||
// dependencies. Types with embedded StructArgs can be used in both the input | ||
// and output parameter positions. | ||
type StructArgs struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In / Out makes it more clear when reading a structure definition, without going into the provider / usage:
- when I see a struct with
dig.In
I quickly associate it with a dependencies of some type. - when I see a struct with
dig.Out
I see that those are some dependencies a provider can provide.
How about let's merge. I can do a live walkthrough of the next PR tomorrow, and we can discuss any naming details we want to tweak. |
<!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description closes #9775 needs #9658 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
Description
closes #9774
This PR defines the low-level API for the dependency injector container to be used for the new app.go wiring discussed in #9182, demoed in #9529, and refined by the App Wiring Working Group.
To see example usage, see container_test.go. All tests are expected to fail as there is no implementation here, just API. Thus the tests are skipped.
This API is inspired by https://github.com/uber-go/dig and https://github.com/uber-go/fx and is intended to be for low-level components, with a higher-level
Module
infrastructure sitting on top of this.The
container
package here is defined as a standalone go module so that this code-base is isolated and self-contained and concerned with doing one thing (dependency injection) well.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change