Fork me on GitHub
#clara
<
2017-01-26
>
mike_ananev16:01:11

hi, there! Question about types. Does it necessary to use defrecord in order to declare fact? Can I use ordinary clojure maps to derive a fact and validate them by clojre.spec?

wparker17:01:35

@mike1452 Clara will use the fact-type-fn to determine what type a fact is for matching against conditions. The docs/examples can probably be improved in this regard but it is alluded to in the generated API docs at http://www.clara-rules.org/apidocs/0.13.0-RC4/clojure/clara.rules.html#var-mk-session

wparker17:01:09

Defrecord is just convenient for some people’s use-cases because it creates a type to match against out of the box

wparker17:01:33

when you use clojure’s type function as the fact-type-fn (which is the default)

wparker17:01:13

also because it allows you to use field names in a rule condition directly i.e.

wparker17:01:20

(defrecord Cold [temperature])

wparker17:01:29

(< temperature 0)

wparker17:01:40

rather than (< (:temperature this) 0))

mike_ananev18:01:50

@wparker thanks! awesome rule engine!

wparker18:01:45

@mike1452 this has come up several times. Ideally we’d have an explanation of the option at http://clara-rules.org at some point when someone gets time to write one but in the meantime I added a quick example at https://github.com/cerner/clara-examples/blob/master/src/main/clojure/clara/examples/fact_type_options.clj

mike_ananev19:01:03

@wparker btw, is it possible to use Clara rules with Apache Flink? We are building online anti-fraud system and evaluating several engines.

wparker20:01:53

Clara currently always runs in a single JVM, although it can be used in a distributed environment if it itself isn’t distributed, and we actually do so. Clara’s architecture would likely facilitate an enhancement to distribute it and if someone were interested in driving that it could be discussed.