-
Notifications
You must be signed in to change notification settings - Fork 316
Implement map value groups support in fx #1279
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
Open
jquirke
wants to merge
10
commits into
uber-go:master
Choose a base branch
from
jquirke:issue_1036
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add support for consuming named value groups as map[string]T, enabling both individual named access and map-based consumption of the same providers. While the core functionality is implemented in dig PR uber-go#381, this commit adds comprehensive fx integration and test coverage. Changes: - Add map_groups_test.go with extensive test coverage for map consumption, interfaces, pointer types, name+group combinations, and edge cases - Enhance decorate_test.go with map decoration tests and validation of slice decorator restrictions for named value groups - Update go.mod to use dig fork with map value groups support - Update CHANGELOG.md to document the new functionality Fixes uber-go#1036 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Test that value groups properly reject non-string map keys (using int as example) with the expected error message from dig validation.
Test map value groups behavior across fx.Module boundaries: - Map consumption across child and parent modules - Nested module hierarchies - Global visibility of groups across all modules - Name conflict detection across module boundaries Verified behavior is consistent with existing slice value groups where all modules see the global group state. Moved tests to module_test.go where they belong since they specifically test fx.Module behavior.
Test that the same value group can be consumed as both map and slice in different parts of the same application. This validates an important real-world use case where hybrid consumption patterns are needed.
This test verifies that map value group decoration chains properly across module boundaries, demonstrating the correct behavior for named value groups as implemented in uber-go/dig#381.
- Add test for soft map group consumption in annotated_test.go - Add test for soft map group decoration in decorate_test.go - Verify soft groups only contain values from executed constructors when consumed as maps - Test both decoration and consumption scenarios with soft map groups 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Demos should be placed in proper location, will be fixed later. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…ption - Add Named Value Groups and Map Consumption section to doc.go - Document providing values with both name and group tags - Show multiple consumption patterns: map, slice, and individual access - Include practical examples with fx.Annotate and struct tags - Explain constraints for map consumption (string keys, all values must have names) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Add demo code in docs/ex/value-groups/maps/ with handlers, feeding, consuming examples - Create documentation in docs/src/value-groups/maps/ explaining map consumption - Update mkdocs.yml to include new map documentation pages - Add dig replace directive to docs/go.mod for map groups support - Include decoration restrictions and error conditions in documentation - Provide working tests demonstrating map vs slice consumption 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Documentation UpdateAdded comprehensive documentation and examples for map value groups: New Documentation
Demo Code
Key Documentation Topics
The documentation follows the existing fx docs pattern with code snippets and comprehensive examples. Ready for review alongside the implementation! |
- Update annotated.go docs to remove outdated mutual exclusivity restriction - Enhance doc.go with clearer examples showing both fx.Out and fx.ResultTags approaches - Add comprehensive test demonstrating fx.Out struct with both name and group tags This confirms that fx.Out structs fully support combining name and group annotations, which was already working but not properly documented or tested. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements support for map value groups consumption via
map[string]Tfor named value groups, enabling both individual named access and map-based access to the same providers.This implements feature requests #1036 #998 by integrating the map value groups functionality from uber-go/dig#381 into fx with comprehensive test coverage.
Changes
Key Features
map[string]Tindexed by provider namesnameandgroupannotations for dual access patternsTest Coverage
Dependencies
Important: This PR currently uses a forked dig dependency (
github.com/jquirke/dig v0.0.0-20250929003136-0b0022552f09) that implements the map value groups functionality. This PR cannot be merged until:The fx implementation and tests are complete and ready, but the underlying dig dependency must be officially released first.
Implements #1036