3

I'm working on allowing my users to create their own ruleset for data that's coming in. All of the data below is sample mock data and not in relation to our product. Example of a rule (there can be many):

CONDITIONS: (IF)
1) title = 'some*'
2) user = 'john'
OUTCOME: (THEN)
1) e-mail me
2) deny request

so in the rule above if a request is made input?title='something'&user='john'&...

it would deny the request and e-mail the user since it matches the condition. if the request is input?title='blah'&user='john' it would allow it to pass since it doesn't match any rules.

I found two ways of doing this but I'm not too happy with it and hoping someone else might have a better solution.

First method

  1. When a user creates a rule it generates a temp file where it writes that rule into a programming language of IF THEN statements
  2. When a new request comes in, it goes through that user's rule-list in the programming language and does the appropriate actions

Second method

  1. When a new request comes in, it gets written into a db
  2. We pull all the conditionals from the db for different rules and run a query against that one row to see if it matches the conditions. If it does, we pass along the outcomes to the script to do the rest

I'm not happy with either of these days. Any insight or help here is much appreciated.

asked Feb 26, 2016 at 17:39
4
  • 1
    You are looking at implementing a rules engine from scratch. You will likely find it easier to use one of the existing ones. Commented Feb 26, 2016 at 17:42
  • what this has to do with c++? Commented Feb 26, 2016 at 18:11
  • @MichaelT do you know of one that I can look at? I had a tough time searching and finding one Commented Feb 26, 2016 at 18:22
  • Category:Rule engines from Wikipedia. Commented Feb 26, 2016 at 19:04

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.