Skip to content

Conversation

@pavelpatrin
Copy link
Collaborator

This pull request refactors the service container's option handling to use an interface-based approach, improving type safety and extensibility. The main changes include replacing the function-based Option type with an interface, introducing option kind identification, and adding helper functions for option type checking.

Refactoring Option Handling

  • Changed the Option type from a function to an interface with apply and kind methods, allowing for more structured and extensible option management. (container.go)
  • Updated NewFactory, NewService, and NewEntrypoint to return the new Option interface, and replaced direct function returns with a newOption constructor that sets the option kind. (container.go) [1] [2] [3] [4] [5]

Option Type Identification

  • Added helper functions IsFactory, IsService, and IsEntrypoint to check the kind of an option, improving clarity and usability when working with different option types. (container.go, README.md) [1] [2]

Internal Implementation Improvements

  • Introduced the option struct to implement the Option interface, encapsulating the option logic and kind string. (container.go)
  • Updated the main container logic to use the new apply method for registering options, replacing direct function calls. (container.go)

These changes make the service container more robust and easier to extend with new option types in the future.

Signed-off-by: Pavel Patrin <ppatrin@nvidia.com>
Signed-off-by: Pavel Patrin <ppatrin@nvidia.com>
@pavelpatrin pavelpatrin deleted the v2-devel-is-opt-checks branch September 26, 2025 14:41
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.

2 participants