-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Change the order in which events are issued #4274
Conversation
Can you describe the problem you are facing that drove you to propose these changes? |
@spencergibb hello, I am writing a PR that collects metrics using these events. However, the information reflected in the registry is unknown when the event occurs. This is because events are issued first before being registered/deleted. @EventListener
public void onEvent(EurekaInstanceRegisteredEvent event) {
final InstanceInfo instanceInfo = event.getInstanceInfo();
instanceRegistry.getInstanceByAppAndId(instanceInfo.getAppName(), instanceInfo.getInstanceId()); <--
} Also, I find it somewhat odd that events are issued before register/delete actions. Isn't that right? |
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.
Thanks for the PR, @heowc. Have added a comment. Please address.
...a-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java
Outdated
Show resolved
Hide resolved
...a-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java
Outdated
Show resolved
Hide resolved
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.
Thanks, @heowc. Looks good, but have added some cosmetic comments. Please take a look.
...a-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java
Outdated
Show resolved
Hide resolved
...a-server/src/main/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistry.java
Outdated
Show resolved
Hide resolved
Build failed. 😭 Is this a flaky test? |
@heowc It's not a flaky test - it's directly caused by the changes made. We are now checking for a boolean result of those operations that we're not getting (the test is not set up to run the full operation including communicating with an Eureka Server). You can stub it appropriately in your tests, but make sure to verify the behaviour against a running Eureka server in your local setup. It's bizarre that it passes for you locally - maybe some old code version cached somewhere? |
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.
Please adjust tests to code changes.
Fixed 🤣 |
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.
Thanks @heowc, please see the comments and fix them.
...ver/src/test/java/org/springframework/cloud/netflix/eureka/server/InstanceRegistryTests.java
Show resolved
Hide resolved
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.
LGTM.
The order in which events are issued should be after the desired processing, but they are preceded.