rules icon indicating copy to clipboard operation
rules copied to clipboard

Redis, rule updates and temporal relations?

Open MStumpp opened this issue 5 years ago • 5 comments

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.

MStumpp avatar Mar 22 '20 21:03 MStumpp

Hi, thanks for asking the questions.

  1. 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
  2. No it is not possible
  3. 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

jruizgit avatar Mar 23 '20 00:03 jruizgit

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)

MStumpp avatar Mar 23 '20 00:03 MStumpp

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 avatar Mar 23 '20 05:03 jruizgit

@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 avatar Jun 04 '20 13:06 nixphix

@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.

zellelin avatar Feb 19 '21 10:02 zellelin