Clojurians
#clara
<
2017-07-28
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

nickowsy18:07:45

hi, I'm new to clara and I'm having a bit of trouble understanding clara's durability. I'm serialize the data, storing the rule base separately. When I restore everything, insert new facts, and fire-rules...my rules are not running again. Rules fire great if I use the original session. i.e. not the one that was restored. I have been looking at https://github.com/cerner/clara-rules/blob/master/src/test/clojure/clara/test_durability.clj and my broken test is at https://github.com/nfox2004/clara-durability/blob/master/test/clara_durability_help/core_test.clj. Any suggestions would be awesome! thanks

wparker19:07:03

@nickowsy from a quick glance over your test I see your original session has a custom :fact-type-fn. You’ll need to supply the same :fact-type-fn that the original function had when deserializing the rulebase. See the 2-argument version of deserialize-rulebase: https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules/durability.clj#L653

wparker19:07:33

So something like (deserialize-rulebase session-serializer {:fact-type-fn your-fact-type-function})

wparker19:07:03

The reason it is that way is that arbitrary Clojure function objects aren’t serializable, so you have to either impose some kind of restriction on the functions used that gives you serializability or require the user to handle it; we went with the latter

nickowsy20:07:41

@wparker thanks a ton! makes total sense :slightly_smiling_face:

dadair23:07:28

Not sure if this question goes against the design of fact-based systems, but is there a way to "update" a fact? That is, say we insert ->Fact x, and then we insert ->Fact y, is it possible to only get a single Fact with updated value y in a query?

dadair23:07:37

concrete example:

(-> (handle test-file test-action) (r/query fields-for :?formRef "/forms/aae-form"))
=>
({:?formRef "/forms/aae-form",
  :?fieldRef "/forms/aae-form/data/order/reason",
  :?field #{#justice.rules.forms.FormField{:formRef "/forms/aae-form",
                                           :fieldRef "/forms/aae-form/data/order/reason",
                                           :descriptor {:type "VALUE",
                                                        :valueType "STRING",
                                                        :value "foo",
                                                        :constraints {:minLength 1, :required true}}}
            #justice.rules.forms.FormField{:formRef "/forms/aae-form",
                                           :fieldRef "/forms/aae-form/data/order/reason",
                                           :descriptor {:type "VALUE",
                                                        :valueType "STRING",
                                                        :value "",
                                                        :constraints {:minLength 1, :required true}}}}})
I'd like the query to return all FormField's with unique :fieldRef; so in the above example if I update the :descriptor :value from "" to "foo", I only want the single fact returned