-
Notifications
You must be signed in to change notification settings - Fork 65
refactor: remove channel monitor #1670
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
Conversation
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Summary of ChangesHello @toddbaert, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively removes the channel monitoring logic, which simplifies the ChannelConnector and removes reliance on an experimental gRPC API. The changes are well-justified and correctly applied across the codebase, including the removal of corresponding tests.
I have a couple of suggestions for further cleanup to complete the refactoring:
- The
ChannelConnectorconstructor signature can be simplified by removing a now-unused parameter. - The
ChannelConnectorTestclass is left without any tests and should either be removed or have a test added for the remaining functionality.
I am having trouble creating individual review comments. Click here to see my feedback.
providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/ChannelConnector.java (35)
The onConnectionEvent parameter is no longer used within the constructor or the class after this refactoring. It should be removed from the method signature to make the API cleaner and prevent confusion.
This change will require updating the constructor calls in RpcResolver and SyncStreamQueueSource.
final FlagdOptions options, ManagedChannel channel) {
providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/common/ChannelConnectorTest.java (88-150)
After removing the tests for the channel monitor, ChannelConnectorTest is left with no actual tests. An empty test class can be misleading and adds to maintenance overhead.
Please consider one of the following options:
- Remove the
ChannelConnectorTest.javafile completely. - Add a new test for the remaining
shutdown()functionality to ensure it behaves as expected.
Here is an example test for the shutdown() method:
@Test
void shutdownShouldShutdownChannel() throws InterruptedException {
ManagedChannel channel = mock(ManagedChannel.class);
when(channel.isShutdown()).thenReturn(false);
// The second argument to the constructor is now unused.
ChannelConnector connector = new ChannelConnector(FlagdOptions.builder().build(), null, channel);
connector.shutdown();
verify(channel).shutdownNow();
verify(channel).awaitTermination(anyLong(), any(TimeUnit.class));
}Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
| @@ -1,151 +0,0 @@ | |||
| package dev.openfeature.contrib.providers.flagd.resolver.common; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gemini suggested I remove this whole test file. I agree, and I think I should also delete the entire ChannelConnector class as I said in my description, but I think I want to do that separately, as that would require small refactors around shutdown which I don't want to add to this PR.
guidobrei
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like all the red removed lines in the diff ❤️
Maybe we should rename the class now to ChannelDisconnector 😆
Haha, ya, I think it's awkward now that it just disconnects, but I want to do that separately. I wanted to make it very clear in this PR what was being removed. |
This PR removes the channel monitor (see thread here).. as Guido put it:
Reasons/justification:
I believe this was previously needed before we made the
eventStream(RPC mode) required, and before @guidobrei optimized and commonized our streaming logic. Now, I think this code is basically dead.If this code really is needed for some reason, I think we probably need e2e tests to exercise whatever situation that is, if those can be reasonably created.
I would like to do more refactors around this (for example we can probably delete the entire
ChannelConnectorclass now, but I wanted to try to keep this PR as clear as possible.