Skip to content

Conversation

@willmostly
Copy link
Contributor

@willmostly willmostly commented Feb 28, 2025

Description

Store rules in the backend database. This simplifies running a cluster of gateways and CRUD operations on the rule set.

This also adds API methods for creating and deleting rules. UI support for create and delete is not included.

Additional context and related issues

Store routing rules in the database. A rule is defined as a name, description, priority, condition and list of actions, with an additional field for identifying the rule evaluation engine. MVEL is currently the only supported engine, however we anticipate supporting more in the future. The engine field is added at this time to avoid future database schema migrations.

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x ) Release notes are required, with the following suggested text:

* Store routing rules in the database

@cla-bot cla-bot bot added the cla-signed label Feb 28, 2025
@willmostly willmostly force-pushed the will/db-routing-rules branch 2 times, most recently from 40bb455 to bfa07f5 Compare March 4, 2025 14:30
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djol.skipHotspotSAAttach=true</argLine>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need this for local testing - I will revert before merging


import java.util.List;

public interface IRoutingRulesManager
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will rename this to RoutingRulesManager once reviews are complete. I have not renamed yet because I renamed the existing RoutingRulesManager to FileBasedRoutingRulesManager, and made changes to the file. Git cannot track a name change followed by creating a new file with the old name, so performing both in the same commit makes the diffs useless.

@willmostly willmostly force-pushed the will/db-routing-rules branch from bfa07f5 to a286173 Compare March 4, 2025 15:08
@willmostly willmostly changed the title Store routing rules in database [WIP] Store routing rules in database Mar 4, 2025
Copy link
Contributor

@posulliv posulliv left a comment

Choose a reason for hiding this comment

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

Code changes look good to me.

Might be worth adding a TODO or creating an issue to add Oracle tests for these once we figure out how to run Oracle tests on arm?

@willmostly
Copy link
Contributor Author

Might be worth adding a TODO or creating an issue to add Oracle tests for these once we figure out how to run Oracle tests on arm?

TestDbRoutingRulesMultipleBackendsOracle in the second commit hits these code paths, but I agree that it would be a good idea to add dedicated tests

@Path("/createRoutingRule")
public Response createRoutingRule(RoutingRule routingRule)
{
routingRulesManager.createRoutingRule(routingRule);
Copy link

@assafsbd assafsbd Mar 12, 2025

Choose a reason for hiding this comment

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

now this is revealed to the outside world through the API, it might be helpful to add validation for easier debugging by consumers and more predictability.


@Override
public List<RoutingRule> getRoutingRules()
{

Choose a reason for hiding this comment

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

I'm not sure how often this gets executed during the gateway lifetime, and how many rules are there on average but in certain conditions it could save some round trips to the db to cache the list of rules here (invalidate on update/delete)

@mosabua
Copy link
Member

mosabua commented Mar 13, 2025

@yaelselig30 could you provide details on your approval .. did you test this? Did you review the code?

@yaelselig30
Copy link

yaelselig30 commented Mar 18, 2025

@mosabua
I reviewed the code and checked the queries in both GatewayBackendDao and RoutingRulesDao—they look well-structured.
I also tested the CRUD operations for RoutingRules, and everything works as expected.
Overall, the code is clear, well-organized, and easy to test.

@willmostly willmostly closed this Mar 20, 2025
@willmostly willmostly deleted the will/db-routing-rules branch March 20, 2025 16:30
@willmostly willmostly restored the will/db-routing-rules branch March 20, 2025 18:08
@mosabua mosabua mentioned this pull request Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants