-
Notifications
You must be signed in to change notification settings - Fork 122
Implement Strict Routing Semantics for Routing Rules #804
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
base: main
Are you sure you want to change the base?
Conversation
|
Just a few remarks:
|
+1 |
|
| List<ProxyBackendConfiguration> backends = gatewayBackendManager.getActiveBackends(routingGroup).stream() | ||
| .filter(backEnd -> isBackendHealthy(backEnd.getName())) | ||
| .toList(); | ||
| if (backends.isEmpty() && strictRouting) { |
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.
This may be a nitpick, but evaluating strictRouting first can short circuit the backends.isEmpty() one, in case it's false. A teeny performance optimization would be to re-order these so it's if (strictRouting && backends.isEmpty())
| .filter(backEnd -> isBackendHealthy(backEnd.getName())) | ||
| .toList(); | ||
| if (strictRouting && backends.isEmpty()) { | ||
| throw new WebApplicationException( |
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.
why WebApplicationException and not IllegalStateException like in IllegalStateException("Number of active backends found zero"))
or maybe a custom Explicit Exception inherited from RouterException?
Description
This PR adds
strictRoutingflag for routing as proposed in #797.Routing rules can now support
strictRouting: Trueto force pinning the query to the routing groupWhen
strictRouting = false (default), the routing behavior remains unchanged.When
strictRouting = true, the gateway would not fall back to default clusters if the pinned backend becomes unavailable. Instead, the query should fail immediately with a 404 error.Testing
mvn clean installTestStochasticRoutingManagerstrictRoutingflag works