Skip to content

Route registry enhancements #478

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

maxmoehl
Copy link
Member

@maxmoehl maxmoehl commented May 6, 2025

Summary

Rework some of the route registry logic to reduce nested ifs and align some of the logic.

Backward Compatibility

Breaking Change? No

@maxmoehl maxmoehl changed the title Maxmoehl/route registry enhancements Route registry enhancements May 6, 2025
@maxmoehl maxmoehl force-pushed the maxmoehl/route-registry-enhancements branch from f58bd8f to 09dd5ac Compare May 7, 2025 05:54
@maxmoehl
Copy link
Member Author

maxmoehl commented May 7, 2025

We've validated this in one of our environments and the metrics now show up with the "refreshed" tag. As expected, the number of route messages labeled as "updated" went down a lot as those are now "refreshed". The logs also behave as expected with the refresh logs (which have a high volume) being not emitted if you set the log level to info.

We also ran the routing-release test suite for gorouter and it passes.

@maxmoehl maxmoehl marked this pull request as ready for review May 7, 2025 13:10
@maxmoehl maxmoehl requested a review from a team as a code owner May 7, 2025 13:10
@maxmoehl maxmoehl linked an issue May 7, 2025 that may be closed by this pull request
}

func (r *RouteRegistry) unregister(uri route.Uri, endpoint *route.Endpoint) {
func (r *RouteRegistry) unregister(uri route.Uri, endpoint *route.Endpoint) (endpointRemoved, routeRemoved bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we pleadse have proper types for endpointRemoved and routeRemoved, similar to the poolPutResult?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well these are just bools... I'd rather not introduce aliases for true and false 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not, still better than having

return true, false
return false, false
return true, true

in the code, where you need to read function signatures to understand the meaning.

Copy link
Contributor

@peanball peanball May 8, 2025

Choose a reason for hiding this comment

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

image
This looks pretty clear to me, at least in IntelliJ/GoLand

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @hoffmaen. The coding would be more readable. But your call.

@hoffmaen
Copy link
Contributor

hoffmaen commented May 7, 2025

One more thing: We log the registration of new routes very deep in the code (in insertRouteKey), but we log the removal of routes in the public function (Unregister). Can we have it both on the same level, ideally in the public function?

@maxmoehl maxmoehl force-pushed the maxmoehl/route-registry-enhancements branch from dc96907 to b49cabf Compare May 8, 2025 08:26
@maxmoehl maxmoehl force-pushed the maxmoehl/route-registry-enhancements branch from b98740e to 1fea46d Compare May 12, 2025 07:03
@@ -88,32 +88,42 @@ func (r *RouteRegistry) Register(uri route.Uri, endpoint *route.Endpoint) {
return
}

endpointAdded := r.register(uri, endpoint)
poolPutResult, routeAdded := r.register(uri, endpoint)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe routePoolAdded instead of routeAdded? It is clearer then.

maxmoehl and others added 3 commits May 12, 2025 13:43
Co-Authored-By: Clemens Hoffmann <[email protected]>
Co-Authored-By: Soha Alboghdady <[email protected]>
Co-Authored-By: Clemens Hoffmann <[email protected]>
Co-Authored-By: Soha Alboghdady <[email protected]>
@maxmoehl maxmoehl force-pushed the maxmoehl/route-registry-enhancements branch from 1fea46d to 0eb9044 Compare May 12, 2025 11:44
@maxmoehl maxmoehl force-pushed the maxmoehl/route-registry-enhancements branch from e1bf949 to e648904 Compare May 13, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Fix Route Registry Metrics to Report Correct Result
5 participants