Skip to content
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

Add interface assertion for delegatingByGVKCache #2732

Closed
ShyunnY opened this issue Mar 26, 2024 · 2 comments
Closed

Add interface assertion for delegatingByGVKCache #2732

ShyunnY opened this issue Mar 26, 2024 · 2 comments

Comments

@ShyunnY
Copy link

ShyunnY commented Mar 26, 2024

When I was reviewing the source code for delegatingByGVKCache, I found it difficult to quickly determine which interfaces this type implements. I had to examine the methods and their return values to understand the implemented interfaces. Since delegatingByGVKCache doesn't have an explicit constructor, we can't infer the implemented interfaces from the return semantics of the constructor.

Therefore, I would like to propose adding interface assertions to the delegatingByGVKCache type, as follows:

var _ Cache = &delegatingByGVKCache{}
var _ client.Reader = &delegatingByGVKCache{}
var _ Informers = &delegatingByGVKCache{}

This feature may not be essential, but it would certainly improve the user experience when reviewing the source code, as it allows for quick identification of the interfaces that the type implements. (At least this can be done without the IDE, and you can quickly learn about its implementation interface.)

@alvaroaleman
Copy link
Member

This type is not even exported, why would it matter? The Cache interface is btw the combination of client.Reader and Informers, so your example is somewhat redundant.

@ShyunnY
Copy link
Author

ShyunnY commented Jun 9, 2024

Thank you for your reply. I thought about it carefully. It is indeed not necessary.

@ShyunnY ShyunnY closed this as completed Jun 9, 2024
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

No branches or pull requests

2 participants