rules
rules copied to clipboard
Redis, rule updates and temporal relations?
I have a few questions I did not find answers for:
1.) How to use a Redis store? In particular, how to configure durable to use Redis? 2.) Is it possible to update the rule set during execution time? 3.) How to model temporal relations of events? E.g. consequent should fire only if event A: { 'type' : 'TypeA' } was occurring n seconds before: event B: { 'type' : 'TypeB' } I found this issue https://github.com/jruizgit/rules/issues/168 but its referring to some other scenario.
Hi, thanks for asking the questions.
- State offloading to Redis can be implemented as an extension. Please follow the example (also available for Python): https://github.com/jruizgit/rules/blob/master/testjs/testdurable.js
- No it is not possible
- You can set a timestamp in your events, you can also use a timer: https://github.com/jruizgit/rules/blob/master/docs/js/reference.md#timers
Thanks for the quick response.
If 1.) works, wouldn't it be possible to just reuse the state stored Redis?
provideDurability(d.getHost());
let's say i run this first:
d.ruleset('test', function() {
whenAll: {
m.subject == 'Hello'
}
run: {
console.log('fired test');
}
});
then restart the program with the following update:
d.ruleset('test', function() {
whenAll: {
m.subject == 'World'
}
run: {
console.log('fired world');
}
});
(or even add another ruleset 'test_2' and attaching it to d)
Yes, you should be able to do that as long as the new ruleset is compatible with the data model of the old one.
@jruizgit I'm looking for Redis store for python, I did check testdynamic.py it seems to be outdated for the current version.
The Host class doesn't have a public run function anymore. Also the get_host() uses a global var for host. In comparison to the js implementation you have mentioned above python extension seems incomplete.
Could you please give me some pointers on offloading the data store to Redis, cause our application is distributed across various worker nodes.
@jruizgit I'm looking for Redis store for python, I did check testdynamic.py it seems to be outdated for the current version.
The Host class doesn't have a public run function anymore. Also the get_host() uses a global var for host. In comparison to the js implementation you have mentioned above python extension seems incomplete.
Could you please give me some pointers on offloading the data store to Redis, cause our application is distributed across various worker nodes. @nixphix hi,could you solve this question.i have the same situation with python.