The Wayback Machine - https://web.archive.org/web/20200911133621/https://github.com/CacheControl/json-rules-engine/issues/208
Skip to content
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

Conditionally Execute Rules in a Tree Structure #208

Open
MattCopenhaver opened this issue May 6, 2020 · 4 comments
Open

Conditionally Execute Rules in a Tree Structure #208

MattCopenhaver opened this issue May 6, 2020 · 4 comments

Comments

@MattCopenhaver
Copy link
Contributor

@MattCopenhaver MattCopenhaver commented May 6, 2020

Hello again @CacheControl!

A recent feature I've been thinking about, that would be beneficial to my use case, is executing multiple rules in a tree structure. The idea is that there are a set of conditions which, when evaluated to true, would indicate the need to execute a particular group of rules.

This would be enormously helpful to us to better organize my rules, but also to improve performance by not executing many of the rules.

Below is the logical model of how I think about the rules:

Screen Shot 2020-05-06 at 10 45 36 AM

Now, I could easily implement this a 7 rules that all execute each time, with the conditions added to each rule. All 7 rules would run and all 7 rules would have more conditions to evaluate. What I'd like to happen, is for the conditions in the diamond to only execute once, then either rules 1-3 or rules 4-7 to execute.

I'd also add that this should be nestable, as in this picture:

Screen Shot 2020-05-06 at 10 54 07 AM

Is this a capability/feature you feel should be added to the engine, or is this something you feel should be done outside of the engine? I would be happy to do a PR to add the capability if you think it would be valuable, or have any guidance on how to add it.

@naveen-shetty
Copy link

@naveen-shetty naveen-shetty commented Jun 5, 2020

Hi @CacheControl, Did you get a chance to look at this request? Would appreciate your thoughts here.

@ozanerturk
Copy link
Contributor

@ozanerturk ozanerturk commented Jun 6, 2020

For Organization:
You are grouping rules but each of these groups has the same event after the evaluation?
Normally each rule should be designed for a particular event that will be processed after evaluation.
I mean the important thing is events, not the grouping rules.
If you have identical events for some different rules maybe that is because they are not separated rules.

For performance,
Ordering the facts with respect to their importance probably solves this problem. Because boolean evaluation will not proceed after first failure occurred

@MattCopenhaver
Copy link
Contributor Author

@MattCopenhaver MattCopenhaver commented Jun 6, 2020

@ozanerturk Each rule would have a different event. The rules in the diagram above, each have their own conditions and different event. Zero to many could fire within a given leaf of the tree.

Yes, it would be possible to meet the same logical need by implementing the segmentation conditions in the first condition of each rule (within an all).

However, the example above is a relatively simple one, where there are only 1 or two segmentation conditions. As the number of segmentation conditions grows, the number of rules grows exponentially and the number of conditions within each rule grows linearly.

@ozanerturk
Copy link
Contributor

@ozanerturk ozanerturk commented Jun 7, 2020

Hmm. isn't that seems like routing for you too?
What if we create a rule that has an event executing related rules?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.