Dynamic Rules Engine that applies defined logic to payload
Link of working Demo here => https://3lihn11xl3.execute-api.us-east-2.amazonaws.com/Prod/
Admin's (use an admin tool [for demo purposes the ui is added to this repo]) create rules using some basic IF/ELSE IF/ELSE conditions in a Visual Basic
fashion.
IF [EventId] = 8000
[IsStatus] = true
ELSE
[IsStatus] = false
ENDIF
Rules Engine converts this Visual Basic code to appliable javascript code (what I call engine code):
if (values["EventId"] == 8000) {
values["IsStatus"] = true;
}
else {
values["IsStatus"] = false;
}
And saves both Admin and Engine to the rule definition stored in a datastore.
When applications want to apply rules... it should generate the payload, with a ruleset name for RulesEngine to get the correct rule definition.
- 'rule' = rule definition for rules engine to apply
- 'values' = parameters for rules engine to apply logic too
{
"rule": "is_event_id_a_status",
"values": {
"EventId": 9580
}
}
That application will post to the ~/Execute
endpoint for rules engine to apply the rule logic against the payload
And in return, based on the logic inside the rule, will return the same payload with updated values/parameters
{
"rule": "is_event_id_a_status",
"values": {
"EventId": 9580,
"IsStatus": false
}
}