Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces support for providing and resolving multiple values of the same type using Element[T] and Slice[T] patterns in the inject package, along with readiness probe functionality for the lifecycle package to enable blocking startup until services are ready.
Key changes:
- Multiple values support: New
Element[T]andSlice[T]types allow multiple providers for the same type T, resolved as a slice - Readiness probes: Optional lifecycle readiness probes that block
Start()until all services signal ready - Internal refactoring: Updated internal data structures from
reflect.TypetotypeKey(type + index) to support Element indexing
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| element.go | Implements Element[T] and Slice[T] types with helper functions for type checking and extraction |
| element_test.go | Comprehensive test coverage for Element[T] and Slice[T] functionality including edge cases |
| inject.go | Core dependency injection updates: typeKey-based maps, resolveSlice logic, and input/output type validation |
| cycle.go | Updated dependency cycle detection to work with typeKey and handle Slice[T] dependencies on Element[T] providers |
| inject_test.go | Additional test cases for Build() method with constructor arguments |
| lifecycle/readiness.go | New ReadinessProbe implementation with Signal() and Error() methods |
| lifecycle/readiness_test.go | Test coverage for readiness probes including multiple probes and nested lifecycles |
| lifecycle/lifecycle.go | Integration of readiness probes into lifecycle Start() with dual collection mechanism |
| README.md | Documentation updates for Element/Slice usage, readiness probes, and nested lifecycles |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces support for providing and resolving multiple values of the same type using a new
Element[T]andSlice[T]pattern in theinjectpackage. It also updates the dependency cycle detection and internal data structures to handle these new types, improves error checking for function input/output types, and expands the documentation with comprehensive examples and explanations for these new features.Key changes:
New feature: Multiple values of the same type
Element[T]andSlice[T]types to allow multiple providers for the same type and to resolve them as a slice ([]T). Includes new helper functions and type checks inelement.go, and updated README with usage examples. [1] [2] [3] [4]Dependency injection core updates
values,providers) to use a newtypeKeystruct (type + index) to support multiple providers forElement[T]types. AddedelementCountsto track the number of providers for each element type. [1] [2]typeKeyinstead of justreflect.Type, and to correctly handleElement[T]andSlice[T]types. [1] [2] [3]API and error handling improvements
IsInputTypeAllowedandIsOutputTypeAllowedto restrict usage ofElement[T]andSlice[T]to appropriate contexts (inputs/outputs). Improved error messages for invalid function signatures. [1] [2]Documentation enhancements
Element[T],Slice[T], readiness probes, and nested lifecycles. Clarified usage and constraints for new features. [1] [2] [3] [4]References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]Provide context or links (Jira ticket, Slack thread) for both the reviewer and your future self: