-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add working memory abstraction #37
Comments
fmbenhassine
added a commit
that referenced
this issue
May 12, 2017
fmbenhassine
added a commit
that referenced
this issue
May 12, 2017
Closed
Version 3.0.0-SNAPSHOT has been deployed (use this repo to import it). Here is sample output for the previous example:
|
Closed
Thanks for the update, will check the new version out. |
This was referenced May 16, 2017
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the real world :
The set of known facts is the working memory of a rules engine. It allows rules to add/remove/modify facts. This is a key concept to implement backward/forward chaining.
Moreover, having a separate working memory decouples a rule from data it operates on. This was the major drawback in Easy Rules v2 which caused a lot of issues regarding thread safety.
So having the following signature of
evaluate
andexecute
methods in theRule
API should make sense:The goal is to add a
Facts
abstraction to represent a set of named facts and a@Fact
annotation to mark a parameter as a fact when using a POJO as a rule. Any java object can be used as a fact (Facts
is aMap<String, Object>
).Here is an example of a rule:
And how to use it:
Easy Rules should make sure to inject the facts (by name) in the parameters of condition and action methods. If a parameter is of type
Facts
, the engine will inject all facts (by type).This new API design should address the major thread safety issue of v2:
fire
method and should be created for each thread (each thread has its own set of data to operate on but the rules and the engine can be reused)The text was updated successfully, but these errors were encountered: