Skip to content

Sample Rules Engine where rules are defined in app config & exposed by API & BPMN that maps request codes to an array of possible rule matches in response.

License

Notifications You must be signed in to change notification settings

conorheffron/rules-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rules-engine

License: GPL v3

Java CI with Maven

Sample Rules defined in app configuration for a set of features

  • Each feature can be enabled or disabled
  • Each rule per feature can have attr, op, & values value/values list.
  • Rule Group logic for keys all & any not implemented - see #13 for intended / expected implementation details.
feature:
  new-checkout:
    enabled: true
    ruleGroups:
      all:
        - { attr: country, op: IN, values: [ "ES", "PT" ] }
        - { attr: appVersion, op: GTE, values: [ "120" ] }
      any:
        - { attr: tier, op: IN, values: [ "gold", "platinum" ] }

  search-v2:
    enabled: false

  beta-banner:
    enabled: true

  old-checkout:
    enabled: true
    ruleGroups:
      all:
        - { attr: country, op: IN, values: [ IRL ] }
      any:
        - { attr: tier, op: IN, values: [ gold, platinum ] }

Build & Run App

mvn clean install spring-boot:run

Read Rules & Store in Map

http://localhost:8080/api/executetask
image

Sample API queries

  • If Match, Return list of rules returned with HTTP Status 200
  • else empty list & 400 Bad Request

Test End-Point

http://localhost:8080/api/test
["ES","PT"]
image

Rule Matcher

No Matches (see application yml)

http://localhost:8080/api/eval?feature=new-checkout&country=IE&appVersion=1&tier=2
image

2 Matches for feature, country, & app version rules

http://localhost:8080/api/eval?feature=new-checkout&country=PT&appVersion=120&tier=2
image

2 Matches for feature, country, & app version rules

http://localhost:8080/api/eval?feature=new-checkout&country=ES&appVersion=400&tier=2

1 Match for feature & country

http://localhost:8080/api/eval?feature=new-checkout&country=ES&appVersion=100&tier=2
image

2 Matches for feature, tier, & country

http://localhost:8080/api/eval?feature=old-checkout&country=IRL&appVersion=100&tier=gold
image

3 Matches for feature, country, app version, & tier

http://localhost:8080/api/eval?feature=new-checkout&country=PT&appVersion=140&tier=gold
image

No Matches -> Feature Disabled

http://localhost:8080/api/eval?feature=search-v2&country=PT&appVersion=140&tier=gold
image

Camunda UI Tools such as Cockpit, Admin Panel & Tasklist (login with credentials in yml)

http://localhost:8080/

Screenshots of Embedded Camunda UI

Start Process

image

Task List

image

Cock Pit

image

About

Sample Rules Engine where rules are defined in app config & exposed by API & BPMN that maps request codes to an array of possible rule matches in response.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages