Skip to content

Add Readiness and Slice support#9

Merged
molon merged 9 commits intomainfrom
readiness
Jan 1, 2026
Merged

Add Readiness and Slice support#9
molon merged 9 commits intomainfrom
readiness

Conversation

@molon
Copy link
Copy Markdown
Contributor

@molon molon commented Jan 1, 2026

This pull request introduces support for providing and resolving multiple values of the same type using a new Element[T] and Slice[T] pattern in the inject package. 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

  • Added Element[T] and Slice[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 in element.go, and updated README with usage examples. [1] [2] [3] [4]

Dependency injection core updates

  • Changed internal maps (values, providers) to use a new typeKey struct (type + index) to support multiple providers for Element[T] types. Added elementCounts to track the number of providers for each element type. [1] [2]
  • Updated dependency cycle detection and resolution logic to work with typeKey instead of just reflect.Type, and to correctly handle Element[T] and Slice[T] types. [1] [2] [3]

API and error handling improvements

  • Added IsInputTypeAllowed and IsOutputTypeAllowed to restrict usage of Element[T] and Slice[T] to appropriate contexts (inputs/outputs). Improved error messages for invalid function signatures. [1] [2]

Documentation enhancements

  • Expanded README with detailed documentation and code samples for Element[T], Slice[T], readiness probes, and nested lifecycles. Clarified usage and constraints for new features. [1] [2] [3] [4]
  • Moved and improved signal handling and readiness probe documentation for better clarity.

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:

  • Jira ticket:
  • Slack thread:

Copilot AI review requested due to automatic review settings January 1, 2026 10:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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] and Slice[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.Type to typeKey (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.

Copy link
Copy Markdown

Copilot AI commented Jan 1, 2026

@molon I've opened a new pull request, #10, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@molon molon merged commit 3a10bfd into main Jan 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants